← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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