← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 37
  2. Hi, Zoya!
  3. 54
  4. Hello, Meera!
  5. 31
  6. 32
  7. console.log()
  8. 81
  9. in the console
  10. a pop-up box
  11. let
  12. .js
  13. 55
  14. Well done, Arjun!
  15. 55
  16. 22
  17. Well done, Aman!
  18. 62
  19. 17
  20. 83
  21. alert()
  22. 45
  23. if
  24. 4
  25. Well done, Kabir!
  26. 27
  27. 41
  28. 19
  29. Well done, Aman!
  30. 9
  31. Hello, Aman!
  32. 59
  33. 25
  34. Hi, Kabir!
  35. 45
  36. 95
  37. 0
  38. <script>
  39. 132
  40. 80

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