← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

HTML and CSS lesson 25: JavaScript basics · Set 857 · 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) .css (b) .jpg (c) .js (d) .html
  2. 2.⚡ 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
  3. 3.⚡ What does this code show?
    let name = "Arjun";
    alert("Welcome, " + name + "!");
    (a) Arjun (b) Welcome, name! (c) Welcome, Arjun! (d) name
  4. 4.⚡ What does this code print? (Look at the quotes!)
    let x = "4";
    let y = 5;
    console.log(x + y);
    (a) Error (b) 9 (c) 45
  5. 5.⚡ What number does this code print?
    let a = 10;
    let b = 4;
    console.log(a * b);
  6. 6.⚡ What does this code show?
    let name = "Arjun";
    alert("Hi, " + name + "!");
    (a) Arjun (b) Hi, name! (c) Hi, Arjun! (d) name
  7. 7.⚡ What does this code print? (Look at the quotes!)
    let x = "4";
    let y = 8;
    console.log(x + y);
    (a) Error (b) 48 (c) 12
  8. 8.⚡ What number does this code print?
    let marks = 29;
    marks = marks + 12;
    marks = marks - 12;
    console.log(marks);
  9. 9.⚡ What does this code show?
    let name = "Riya";
    alert("Hi, " + name + "!");
    (a) Hi, Riya! (b) Riya (c) name (d) Hi, name!
  10. 10.⚡ What number does this code print?
    let a = 7;
    let b = 8;
    console.log(a * b);
  11. 11.⚡ What does alert() show? (a) a new tab (b) a picture (c) a pop-up box (d) a table
  12. 12.⚡ What does this code print? (Look at the quotes!)
    let x = "6";
    let y = 9;
    console.log(x + y);
    (a) 69 (b) 15 (c) Error
  13. 13.⚡ What does this code print? (Look at the quotes!)
    let x = "5";
    let y = 5;
    console.log(x + y);
    (a) 10 (b) Error (c) 55
  14. 14.⚡ What does this code show?
    let name = "Zoya";
    console.log("Welcome, " + name + "!");
    (a) Zoya (b) Welcome, name! (c) name (d) Welcome, Zoya!
  15. 15.⚡ What number does this code print?
    let runs = 22;
    runs = runs + 17;
    runs = runs - 8;
    console.log(runs);
  16. 16.⚡ What number does this code print?
    let a = 28;
    let b = 3;
    console.log(a - b);
  17. 17.⚡ What number does this code print?
    let a = 12;
    let b = 10;
    console.log(a * b);
  18. 18.⚡ Which JavaScript word runs code when true? (a) for (b) alert() (c) if (d) let
  19. 19.⚡ What number does this code print?
    let runs = 28;
    runs = runs + 4;
    runs = runs - 19;
    console.log(runs);
  20. 20.⚡ What number does this code print?
    let a = 47;
    let b = 39;
    console.log(a + b);
  21. 21.⚡ What number does this code print?
    let a = 28;
    let b = 11;
    console.log(a - b);
  22. 22.⚡ What does this code print? (Look at the quotes!)
    let x = "1";
    let y = 9;
    console.log(x + y);
    (a) 10 (b) 19 (c) Error
  23. 23.⚡ What does this code show?
    let name = "Meera";
    console.log("Well done, " + name + "!");
    (a) Well done, Meera! (b) Well done, name! (c) Meera (d) name
  24. 24.⚡ Which JavaScript word repeats code? (a) let (b) if (c) for (d) console.log()
  25. 25.⚡ Which JavaScript word shows a pop-up box? (a) if (b) console.log() (c) alert() (d) let
  26. 26.⚡ What does this code show?
    let name = "Kabir";
    alert("Hi, " + name + "!");
    (a) name (b) Kabir (c) Hi, name! (d) Hi, Kabir!
  27. 27.⚡ Which JavaScript word writes in the console? (a) alert() (b) let (c) console.log() (d) if
  28. 28.⚡ What number does this code print?
    let a = 45;
    let b = 9;
    console.log(a - b);
  29. 29.⚡ What number does this code print?
    let books = 24;
    books = books + 4;
    books = books - 7;
    console.log(books);
  30. 30.⚡ What does this code print? (Look at the quotes!)
    let x = "4";
    let y = 9;
    console.log(x + y);
    (a) 49 (b) 13 (c) Error
  31. 31.⚡ What number does this code print?
    let a = 24;
    let b = 6;
    console.log(a - b);
  32. 32.⚡ Which tag holds JavaScript in a page? (a) <js> (b) <script> (c) <code> (d) <style>
  33. 33.⚡ What does this code print? (Look at the quotes!)
    let x = "1";
    let y = 3;
    console.log(x + y);
    (a) 4 (b) Error (c) 13
  34. 34.⚡ What does this code show?
    let name = "Arjun";
    console.log("Well done, " + name + "!");
    (a) Arjun (b) Well done, name! (c) name (d) Well done, Arjun!
  35. 35.⚡ What number does this code print?
    let a = 2;
    let b = 12;
    console.log(a * b);
  36. 36.⚡ What number does this code print?
    let books = 6;
    books = books + 9;
    books = books - 4;
    console.log(books);
  37. 37.⚡ What does this code show?
    let name = "Kabir";
    console.log("Well done, " + name + "!");
    (a) Well done, name! (b) Kabir (c) Well done, Kabir! (d) name
  38. 38.⚡ Which JavaScript word makes a new variable? (a) let (b) console.log() (c) for (d) alert()
  39. 39.⚡ What number does this code print?
    let a = 32;
    let b = 18;
    console.log(a - b);
  40. 40.⚡ What does this code print? (Look at the quotes!)
    let x = "4";
    let y = 4;
    console.log(x + y);
    (a) 8 (b) Error (c) 44

Answer key

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

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