← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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