← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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