← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 99
  2. 44
  3. 45
  4. .js
  5. for
  6. <script>
  7. let
  8. Hi, Meera!
  9. 8
  10. alert()
  11. if
  12. 49
  13. 55
  14. 4
  15. 54
  16. 76
  17. console.log()
  18. Welcome, Aman!
  19. Hello, Kabir!
  20. 8
  21. 1
  22. 108
  23. a pop-up box
  24. let
  25. 9
  26. 27
  27. 49
  28. 77
  29. actions and changes
  30. Hello, Riya!
  31. 27
  32. 96
  33. 3
  34. 65
  35. 4
  36. 15
  37. 97
  38. 40
  39. 96
  40. 76

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