← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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