← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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