← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. let
  2. alert()
  3. 14
  4. .js
  5. Welcome, Zoya!
  6. a pop-up box
  7. for
  8. 92
  9. 29
  10. 3
  11. 0
  12. 24
  13. 82
  14. 12
  15. 21
  16. let
  17. console.log()
  18. 80
  19. 5
  20. 60
  21. 9
  22. if
  23. 21
  24. 72
  25. Hello, Riya!
  26. 48
  27. 6
  28. Welcome, Kabir!
  29. 99
  30. in the console
  31. 29
  32. <script>
  33. Hi, Aman!
  34. Welcome, Aman!
  35. 52
  36. 96
  37. 42
  38. Welcome, Meera!
  39. actions and changes
  40. 15

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