← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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