← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. if
  2. Hello, Arjun!
  3. let
  4. 46
  5. 12
  6. 23
  7. 66
  8. alert()
  9. a pop-up box
  10. 5
  11. Hello, Riya!
  12. 57
  13. 27
  14. 23
  15. Hello, Zoya!
  16. 74
  17. for
  18. 10
  19. 19
  20. Hello, Kabir!
  21. <script>
  22. Well done, Zoya!
  23. let
  24. 44
  25. 58
  26. 21
  27. 1
  28. .js
  29. 50
  30. Well done, Aman!
  31. 16
  32. 0
  33. in the console
  34. 4
  35. Hello, Meera!
  36. 0
  37. 33
  38. 18
  39. 11
  40. Well done, Aman!

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