← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 23
  2. in the console
  3. console.log()
  4. let
  5. 79
  6. 20
  7. 38
  8. 21
  9. Hi, Aman!
  10. alert()
  11. Welcome, Riya!
  12. if
  13. for
  14. <script>
  15. Hi, Riya!
  16. 6
  17. .js
  18. 28
  19. 16
  20. 54
  21. 67
  22. 2
  23. 43
  24. Well done, Zoya!
  25. 39
  26. 4
  27. let
  28. 32
  29. 16
  30. Welcome, Aman!
  31. 44
  32. 68
  33. 36
  34. Hi, Aman!
  35. 1
  36. 6
  37. 41
  38. 6
  39. 15
  40. 120

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