← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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