← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. alert()
  2. a pop-up box
  3. 46
  4. <script>
  5. Hi, Arjun!
  6. actions and changes
  7. 14
  8. 41
  9. 9
  10. 6
  11. 0
  12. Hi, Arjun!
  13. 22
  14. 11
  15. 24
  16. .js
  17. 12
  18. 45
  19. 13
  20. console.log()
  21. 18
  22. 30
  23. in the console
  24. Well done, Meera!
  25. 2
  26. if
  27. 31
  28. 15
  29. for
  30. let
  31. 59
  32. 85
  33. 16
  34. 35
  35. Well done, Aman!
  36. 20
  37. 19
  38. 11
  39. 42
  40. Hi, Zoya!

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