← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. in the console
  2. 82
  3. 11
  4. 48
  5. <script>
  6. 26
  7. let
  8. 16
  9. Hi, Meera!
  10. for
  11. Hello, Arjun!
  12. 63
  13. 17
  14. 77
  15. 9
  16. let
  17. 49
  18. 51
  19. 46
  20. 31
  21. 40
  22. 51
  23. alert()
  24. Welcome, Arjun!
  25. Well done, Kabir!
  26. 26
  27. 3
  28. 47
  29. 83
  30. 20
  31. .js
  32. 2
  33. if
  34. 95
  35. 21
  36. console.log()
  37. 39
  38. 3
  39. 67
  40. Well done, Meera!

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