← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 4
  2. for
  3. 21
  4. 74
  5. if
  6. 24
  7. 3
  8. 24
  9. 25
  10. 50
  11. alert()
  12. 72
  13. 80
  14. Hi, Kabir!
  15. let
  16. 14
  17. 81
  18. 81
  19. 48
  20. 61
  21. .js
  22. 56
  23. in the console
  24. 82
  25. 19
  26. console.log()
  27. actions and changes
  28. 47
  29. 13
  30. 25
  31. 15
  32. 61
  33. let
  34. Hello, Riya!
  35. <script>
  36. 9
  37. 6
  38. 32
  39. 12
  40. 5

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