← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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