← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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