← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. <script>
  2. let
  3. 14
  4. console.log()
  5. alert()
  6. 81
  7. Welcome, Riya!
  8. 4
  9. 44
  10. 48
  11. 31
  12. 40
  13. 13
  14. let
  15. for
  16. 23
  17. 99
  18. 54
  19. 45
  20. 22
  21. 90
  22. 74
  23. 23
  24. 36
  25. 14
  26. 21
  27. 20
  28. Well done, Aman!
  29. 50
  30. in the console
  31. 39
  32. a pop-up box
  33. 97
  34. 28
  35. 17
  36. 14
  37. 4
  38. 17
  39. Well done, Riya!
  40. 7

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