← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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