← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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