← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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