← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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