← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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