← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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