← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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