← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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