← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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