← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. in the console
  2. a pop-up box
  3. 2
  4. 37
  5. 12
  6. 98
  7. 18
  8. 49
  9. 34
  10. 86
  11. 71
  12. alert()
  13. 88
  14. .js
  15. 14
  16. 15
  17. 51
  18. 21
  19. 16
  20. Well done, Zoya!
  21. 50
  22. for
  23. 38
  24. Welcome, Aman!
  25. 4
  26. 61
  27. let
  28. if
  29. Hi, Arjun!
  30. 24
  31. 63
  32. 32
  33. Welcome, Kabir!
  34. 44
  35. <script>
  36. Hi, Meera!
  37. 53
  38. 13
  39. Well done, Meera!
  40. 100

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