← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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