← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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