← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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