← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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