← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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