← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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