← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. .js
  2. 82
  3. 71
  4. 20
  5. Well done, Aman!
  6. if
  7. actions and changes
  8. <script>
  9. 39
  10. let
  11. 17
  12. 26
  13. in the console
  14. 83
  15. 5
  16. console.log()
  17. 28
  18. 21
  19. 26
  20. Well done, Meera!
  21. 68
  22. 37
  23. 22
  24. 23
  25. 19
  26. a pop-up box
  27. 84
  28. let
  29. Hello, Meera!
  30. 91
  31. alert()
  32. Hello, Arjun!
  33. for
  34. 36
  35. 20
  36. Well done, Aman!
  37. 99
  38. 63
  39. 72
  40. 40

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