← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. a pop-up box
  2. in the console
  3. 54
  4. 50
  5. console.log()
  6. 8
  7. 25
  8. alert()
  9. 13
  10. if
  11. let
  12. actions and changes
  13. 90
  14. 35
  15. for
  16. Hello, Kabir!
  17. Well done, Arjun!
  18. Hello, Zoya!
  19. 63
  20. 88
  21. 19
  22. 38
  23. let
  24. 42
  25. Hello, Aman!
  26. 74
  27. 80
  28. 5
  29. .js
  30. 60
  31. 75
  32. 8
  33. 16
  34. Well done, Arjun!
  35. <script>
  36. 37
  37. 12
  38. 18
  39. Well done, Meera!
  40. Well done, Aman!

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