← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. let
  2. 80
  3. 32
  4. 36
  5. let
  6. 31
  7. console.log()
  8. alert()
  9. 26
  10. 20
  11. 110
  12. if
  13. 65
  14. 28
  15. 7
  16. 81
  17. 32
  18. 18
  19. Hello, Zoya!
  20. 5
  21. 10
  22. for
  23. .js
  24. actions and changes
  25. 17
  26. 132
  27. Hi, Riya!
  28. 132
  29. 1
  30. in the console
  31. 56
  32. Hi, Aman!
  33. 79
  34. 56
  35. 18
  36. 88
  37. 36
  38. <script>
  39. 6
  40. 6

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