← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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