← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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