← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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