← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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