← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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