← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

HTML and CSS lesson 25: JavaScript basics · Set 627 · 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.⚡ What number does this code print?
    let a = 11;
    let b = 9;
    console.log(a * b);
  2. 2.⚡ What number does this code print?
    let a = 4;
    let b = 4;
    console.log(a * b);
  3. 3.⚡ What number does this code print?
    let a = 9;
    let b = 4;
    console.log(a * b);
  4. 4.⚡ What number does this code print?
    let a = 49;
    let b = 40;
    console.log(a - b);
  5. 5.⚡ What number does this code print?
    let coins = 15;
    coins = coins + 10;
    coins = coins - 6;
    console.log(coins);
  6. 6.⚡ Which JavaScript word writes in the console? (a) let (b) alert() (c) console.log() (d) if
  7. 7.⚡ What does this code print? (Look at the quotes!)
    let x = "8";
    let y = 3;
    console.log(x + y);
    (a) Error (b) 11 (c) 83
  8. 8.⚡ Which JavaScript word makes a new variable? (a) if (b) for (c) let (d) alert()
  9. 9.⚡ What does this code show?
    let name = "Meera";
    console.log("Hello, " + name + "!");
    (a) Hello, name! (b) Hello, Meera! (c) Meera (d) name
  10. 10.⚡ What number does this code print?
    let a = 23;
    let b = 10;
    console.log(a - b);
  11. 11.⚡ What does this code show?
    let name = "Aman";
    console.log("Hello, " + name + "!");
    (a) name (b) Hello, name! (c) Aman (d) Hello, Aman!
  12. 12.⚡ Which JavaScript word repeats code? (a) let (b) console.log() (c) alert() (d) for
  13. 13.⚡ What does this code show?
    let name = "Kabir";
    console.log("Hi, " + name + "!");
    (a) Kabir (b) Hi, name! (c) name (d) Hi, Kabir!
  14. 14.⚡ Which JavaScript word runs code when true? (a) alert() (b) for (c) if (d) console.log()
  15. 15.⚡ What does this code show?
    let name = "Meera";
    console.log("Hi, " + name + "!");
    (a) Meera (b) name (c) Hi, Meera! (d) Hi, name!
  16. 16.⚡ What does this code print? (Look at the quotes!)
    let x = "7";
    let y = 1;
    console.log(x + y);
    (a) Error (b) 8 (c) 71
  17. 17.⚡ What number does this code print?
    let a = 40;
    let b = 4;
    console.log(a - b);
  18. 18.⚡ What number does this code print?
    let a = 30;
    let b = 9;
    console.log(a + b);
  19. 19.⚡ What number does this code print?
    let a = 58;
    let b = 4;
    console.log(a + b);
  20. 20.⚡ What number does this code print?
    let marks = 9;
    marks = marks + 14;
    marks = marks - 1;
    console.log(marks);
  21. 21.⚡ What does this code show?
    let name = "Riya";
    alert("Hi, " + name + "!");
    (a) Riya (b) name (c) Hi, name! (d) Hi, Riya!
  22. 22.⚡ What does JavaScript add to a web page? (a) actions and changes (b) only colours (c) the page title (d) the domain name
  23. 23.⚡ What number does this code print?
    let a = 36;
    let b = 1;
    console.log(a + b);
  24. 24.⚡ Which JavaScript word shows a pop-up box? (a) let (b) alert() (c) console.log() (d) for
  25. 25.⚡ What does this code print? (Look at the quotes!)
    let x = "1";
    let y = 3;
    console.log(x + y);
    (a) 4 (b) Error (c) 13
  26. 26.⚡ What does this code show?
    let name = "Kabir";
    alert("Well done, " + name + "!");
    (a) Well done, name! (b) Kabir (c) name (d) Well done, Kabir!
  27. 27.⚡ What number does this code print?
    let a = 54;
    let b = 20;
    console.log(a + b);
  28. 28.⚡ What number does this code print?
    let coins = 14;
    coins = coins + 5;
    coins = coins - 4;
    console.log(coins);
  29. 29.⚡ What does alert() show? (a) a pop-up box (b) a table (c) a picture (d) a new tab
  30. 30.⚡ What does this code print? (Look at the quotes!)
    let x = "3";
    let y = 2;
    console.log(x + y);
    (a) 32 (b) Error (c) 5
  31. 31.⚡ A JavaScript file usually ends with which extension? (a) .jpg (b) .html (c) .css (d) .js
  32. 32.⚡ What number does this code print?
    let a = 17;
    let b = 12;
    console.log(a - b);
  33. 33.⚡ What does this code show?
    let name = "Zoya";
    alert("Well done, " + name + "!");
    (a) Zoya (b) name (c) Well done, name! (d) Well done, Zoya!
  34. 34.⚡ What number does this code print?
    let a = 12;
    let b = 6;
    console.log(a - b);
  35. 35.⚡ Where does console.log() show its output? (a) in the console (b) on the title bar (c) in the address bar (d) on the printer
  36. 36.⚡ Which tag holds JavaScript in a page? (a) <code> (b) <script> (c) <style> (d) <js>
  37. 37.⚡ What does this code print? (Look at the quotes!)
    let x = "4";
    let y = 3;
    console.log(x + y);
    (a) 43 (b) 7 (c) Error
  38. 38.⚡ What does this code print? (Look at the quotes!)
    let x = "4";
    let y = 4;
    console.log(x + y);
    (a) 8 (b) 44 (c) Error
  39. 39.⚡ What number does this code print?
    let a = 19;
    let b = 9;
    console.log(a - b);
  40. 40.⚡ What number does this code print?
    let a = 21;
    let b = 1;
    console.log(a + b);

Answer key

  1. 99
  2. 16
  3. 36
  4. 9
  5. 19
  6. console.log()
  7. 83
  8. let
  9. Hello, Meera!
  10. 13
  11. Hello, Aman!
  12. for
  13. Hi, Kabir!
  14. if
  15. Hi, Meera!
  16. 71
  17. 36
  18. 39
  19. 62
  20. 22
  21. Hi, Riya!
  22. actions and changes
  23. 37
  24. alert()
  25. 13
  26. Well done, Kabir!
  27. 74
  28. 15
  29. a pop-up box
  30. 32
  31. .js
  32. 5
  33. Well done, Zoya!
  34. 6
  35. in the console
  36. <script>
  37. 43
  38. 44
  39. 10
  40. 22

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