← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. actions and changes
  2. for
  3. in the console
  4. console.log()
  5. <script>
  6. let
  7. if
  8. Well done, Arjun!
  9. 58
  10. let
  11. 39
  12. 65
  13. 14
  14. 24
  15. 12
  16. alert()
  17. 0
  18. 6
  19. 39
  20. 88
  21. 88
  22. a pop-up box
  23. 68
  24. 3
  25. 74
  26. 72
  27. 96
  28. .js
  29. 20
  30. 57
  31. 41
  32. 18
  33. Welcome, Aman!
  34. 87
  35. 56
  36. 8
  37. 13
  38. 21
  39. 43
  40. 12

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