← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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