← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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