← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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