← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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