← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. for
  2. 22
  3. console.log()
  4. .js
  5. let
  6. 39
  7. Hello, Meera!
  8. Hello, Kabir!
  9. in the console
  10. if
  11. 56
  12. 97
  13. 25
  14. Hi, Aman!
  15. Well done, Zoya!
  16. 96
  17. Hello, Arjun!
  18. <script>
  19. Well done, Arjun!
  20. 62
  21. alert()
  22. Welcome, Zoya!
  23. 0
  24. 22
  25. 40
  26. 39
  27. actions and changes
  28. 17
  29. 21
  30. 66
  31. 33
  32. 43
  33. Hello, Riya!
  34. 26
  35. 16
  36. let
  37. 0
  38. Well done, Aman!
  39. 17
  40. 17

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