← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 55
  2. 121
  3. 96
  4. if
  5. Hi, Meera!
  6. 21
  7. let
  8. 77
  9. 42
  10. .js
  11. actions and changes
  12. alert()
  13. 5
  14. console.log()
  15. 30
  16. 3
  17. 71
  18. Hello, Meera!
  19. 55
  20. 9
  21. 98
  22. 27
  23. 69
  24. in the console
  25. 32
  26. 39
  27. Hi, Zoya!
  28. 3
  29. 18
  30. 8
  31. 29
  32. 24
  33. 27
  34. <script>
  35. 17
  36. 3
  37. 132
  38. for
  39. 37
  40. 6

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