← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 11
  2. console.log()
  3. 16
  4. 22
  5. if
  6. 68
  7. for
  8. 26
  9. 29
  10. 61
  11. 35
  12. <script>
  13. Welcome, Zoya!
  14. alert()
  15. 68
  16. .js
  17. Well done, Kabir!
  18. Hi, Arjun!
  19. Welcome, Arjun!
  20. Well done, Aman!
  21. 47
  22. 11
  23. 85
  24. actions and changes
  25. 0
  26. 38
  27. 55
  28. 39
  29. a pop-up box
  30. 94
  31. 22
  32. 26
  33. let
  34. 46
  35. 63
  36. 24
  37. Hi, Kabir!
  38. in the console
  39. 6
  40. Welcome, Zoya!

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