← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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