← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. let
  2. in the console
  3. console.log()
  4. 92
  5. 1
  6. 4
  7. 15
  8. if
  9. 3
  10. 45
  11. 71
  12. 8
  13. alert()
  14. a pop-up box
  15. 17
  16. for
  17. Well done, Arjun!
  18. 4
  19. Well done, Riya!
  20. 86
  21. <script>
  22. Hello, Meera!
  23. let
  24. .js
  25. 96
  26. 50
  27. 44
  28. 3
  29. Hello, Zoya!
  30. Hi, Arjun!
  31. 91
  32. Hi, Kabir!
  33. 15
  34. 1
  35. 55
  36. 49
  37. 48
  38. 65
  39. 7
  40. Hi, Meera!

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