← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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