← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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