← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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