← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 20
  2. let
  3. 42
  4. for
  5. 97
  6. Well done, Arjun!
  7. actions and changes
  8. Hello, Meera!
  9. .js
  10. 65
  11. a pop-up box
  12. 3
  13. 23
  14. 32
  15. <script>
  16. 52
  17. 53
  18. alert()
  19. 64
  20. 28
  21. 23
  22. 66
  23. 67
  24. 33
  25. 86
  26. 26
  27. Hi, Kabir!
  28. 18
  29. Well done, Aman!
  30. in the console
  31. 48
  32. 69
  33. 64
  34. 61
  35. 56
  36. console.log()
  37. Welcome, Meera!
  38. 80
  39. if
  40. Hi, Arjun!

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