← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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