← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 19
  2. 23
  3. 3
  4. let
  5. 70
  6. alert()
  7. 18
  8. for
  9. .js
  10. 1
  11. in the console
  12. 57
  13. 78
  14. let
  15. 87
  16. console.log()
  17. 52
  18. 26
  19. 9
  20. Well done, Aman!
  21. actions and changes
  22. 38
  23. <script>
  24. 88
  25. 3
  26. 53
  27. Hi, Zoya!
  28. 11
  29. Welcome, Aman!
  30. 6
  31. 72
  32. 1
  33. 0
  34. 5
  35. a pop-up box
  36. Well done, Aman!
  37. 12
  38. 19
  39. 63
  40. Hello, Zoya!

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