← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

HTML and CSS lesson 25: JavaScript basics · Set 807 · 40 questions
TalentJR

Code tip (Line by line): let x = 5; makes a variable x holding 5; x = x + 2; changes it to 7. console.log(…) writes in the console; alert(…) shows a pop-up box. Text in quotes + anything = joined text: "5" + 3 → "53".

NameDateTime takenScore ___ / 40
  1. 1.⚡ Which JavaScript word makes a new variable? (a) if (b) for (c) alert() (d) let
  2. 2.⚡ What does this code print? (Look at the quotes!)
    let x = "9";
    let y = 5;
    console.log(x + y);
    (a) Error (b) 95 (c) 14
  3. 3.⚡ What does this code show?
    let name = "Kabir";
    alert("Hello, " + name + "!");
    (a) Kabir (b) Hello, name! (c) name (d) Hello, Kabir!
  4. 4.⚡ What does this code print? (Look at the quotes!)
    let x = "7";
    let y = 3;
    console.log(x + y);
    (a) 10 (b) Error (c) 73
  5. 5.⚡ What does this code show?
    let name = "Riya";
    console.log("Hi, " + name + "!");
    (a) name (b) Hi, name! (c) Hi, Riya! (d) Riya
  6. 6.⚡ Which JavaScript word repeats code? (a) alert() (b) if (c) for (d) let
  7. 7.⚡ What does this code print? (Look at the quotes!)
    let x = "9";
    let y = 6;
    console.log(x + y);
    (a) Error (b) 15 (c) 96
  8. 8.⚡ What number does this code print?
    let a = 19;
    let b = 24;
    console.log(a + b);
  9. 9.⚡ What does this code print? (Look at the quotes!)
    let x = "3";
    let y = 5;
    console.log(x + y);
    (a) 8 (b) 35 (c) Error
  10. 10.⚡ What does alert() show? (a) a picture (b) a new tab (c) a pop-up box (d) a table
  11. 11.⚡ Which JavaScript word writes in the console? (a) alert() (b) for (c) if (d) console.log()
  12. 12.⚡ What number does this code print?
    let a = 26;
    let b = 8;
    console.log(a + b);
  13. 13.⚡ What number does this code print?
    let a = 51;
    let b = 5;
    console.log(a + b);
  14. 14.⚡ What number does this code print?
    let a = 35;
    let b = 28;
    console.log(a + b);
  15. 15.⚡ What number does this code print?
    let a = 16;
    let b = 33;
    console.log(a + b);
  16. 16.⚡ What number does this code print?
    let a = 8;
    let b = 2;
    console.log(a * b);
  17. 17.⚡ What does this code show?
    let name = "Zoya";
    console.log("Well done, " + name + "!");
    (a) Well done, name! (b) Well done, Zoya! (c) name (d) Zoya
  18. 18.⚡ What does this code print? (Look at the quotes!)
    let x = "1";
    let y = 1;
    console.log(x + y);
    (a) 2 (b) 11 (c) Error
  19. 19.⚡ What number does this code print?
    let a = 34;
    let b = 12;
    console.log(a - b);
  20. 20.⚡ Which JavaScript word shows a pop-up box? (a) alert() (b) console.log() (c) if (d) for
  21. 21.⚡ What number does this code print?
    let a = 28;
    let b = 18;
    console.log(a - b);
  22. 22.⚡ Which word makes a new variable? (a) make (b) let (c) put (d) give
  23. 23.⚡ What does this code show?
    let name = "Meera";
    console.log("Welcome, " + name + "!");
    (a) Welcome, name! (b) name (c) Meera (d) Welcome, Meera!
  24. 24.⚡ What number does this code print?
    let a = 45;
    let b = 17;
    console.log(a - b);
  25. 25.⚡ Where does console.log() show its output? (a) in the address bar (b) on the title bar (c) on the printer (d) in the console
  26. 26.⚡ What does this code show?
    let name = "Riya";
    alert("Hi, " + name + "!");
    (a) Riya (b) name (c) Hi, name! (d) Hi, Riya!
  27. 27.⚡ What number does this code print?
    let coins = 9;
    coins = coins + 20;
    coins = coins - 4;
    console.log(coins);
  28. 28.⚡ What does JavaScript add to a web page? (a) the domain name (b) actions and changes (c) only colours (d) the page title
  29. 29.⚡ What does this code print? (Look at the quotes!)
    let x = "7";
    let y = 5;
    console.log(x + y);
    (a) Error (b) 12 (c) 75
  30. 30.⚡ What number does this code print?
    let a = 4;
    let b = 6;
    console.log(a * b);
  31. 31.⚡ What does this code print? (Look at the quotes!)
    let x = "4";
    let y = 2;
    console.log(x + y);
    (a) Error (b) 42 (c) 6
  32. 32.⚡ What number does this code print?
    let a = 5;
    let b = 10;
    console.log(a * b);
  33. 33.⚡ What number does this code print?
    let a = 20;
    let b = 13;
    console.log(a + b);
  34. 34.⚡ What number does this code print?
    let score = 25;
    score = score + 19;
    score = score - 5;
    console.log(score);
  35. 35.⚡ What number does this code print?
    let a = 2;
    let b = 4;
    console.log(a * b);
  36. 36.⚡ What number does this code print?
    let a = 4;
    let b = 12;
    console.log(a * b);
  37. 37.⚡ What does this code print? (Look at the quotes!)
    let x = "6";
    let y = 9;
    console.log(x + y);
    (a) Error (b) 15 (c) 69
  38. 38.⚡ What number does this code print?
    let runs = 19;
    runs = runs + 5;
    runs = runs - 12;
    console.log(runs);
  39. 39.⚡ What does this code show?
    let name = "Zoya";
    alert("Welcome, " + name + "!");
    (a) Welcome, name! (b) Welcome, Zoya! (c) Zoya (d) name
  40. 40.⚡ What does this code print? (Look at the quotes!)
    let x = "1";
    let y = 2;
    console.log(x + y);
    (a) 12 (b) 3 (c) Error

Answer key

  1. let
  2. 95
  3. Hello, Kabir!
  4. 73
  5. Hi, Riya!
  6. for
  7. 96
  8. 43
  9. 35
  10. a pop-up box
  11. console.log()
  12. 34
  13. 56
  14. 63
  15. 49
  16. 16
  17. Well done, Zoya!
  18. 11
  19. 22
  20. alert()
  21. 10
  22. let
  23. Welcome, Meera!
  24. 28
  25. in the console
  26. Hi, Riya!
  27. 25
  28. actions and changes
  29. 75
  30. 24
  31. 42
  32. 50
  33. 33
  34. 39
  35. 8
  36. 48
  37. 69
  38. 12
  39. Welcome, Zoya!
  40. 12

Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids