← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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