← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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