← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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