← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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