← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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