← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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