← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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