← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. for
  2. alert()
  3. Hello, Aman!
  4. 76
  5. <script>
  6. in the console
  7. a pop-up box
  8. if
  9. 12
  10. .js
  11. 13
  12. let
  13. 13
  14. 55
  15. 95
  16. console.log()
  17. 2
  18. let
  19. 12
  20. Welcome, Aman!
  21. Hi, Aman!
  22. 9
  23. 59
  24. 6
  25. 3
  26. 21
  27. 22
  28. Hi, Riya!
  29. 31
  30. Hello, Meera!
  31. 30
  32. Well done, Meera!
  33. 33
  34. 38
  35. 41
  36. Well done, Zoya!
  37. actions and changes
  38. 1
  39. 16
  40. 43

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