← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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