← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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