← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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