← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 33
  2. 24
  3. .js
  4. 81
  5. if
  6. a pop-up box
  7. 8
  8. 17
  9. let
  10. alert()
  11. 84
  12. <script>
  13. 2
  14. Welcome, Riya!
  15. 19
  16. 12
  17. 94
  18. 57
  19. 74
  20. 29
  21. 42
  22. 39
  23. 44
  24. for
  25. 16
  26. 83
  27. let
  28. console.log()
  29. 9
  30. 46
  31. 91
  32. 7
  33. 21
  34. in the console
  35. 14
  36. 37
  37. 44
  38. Hello, Arjun!
  39. 23
  40. 22

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