← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. .js
  2. let
  3. 15
  4. 53
  5. if
  6. <script>
  7. 91
  8. 0
  9. in the console
  10. Hi, Meera!
  11. 13
  12. 22
  13. Hello, Arjun!
  14. 22
  15. 11
  16. 31
  17. 16
  18. a pop-up box
  19. 53
  20. 71
  21. 21
  22. actions and changes
  23. 7
  24. alert()
  25. 86
  26. 32
  27. 0
  28. for
  29. 56
  30. 20
  31. 28
  32. 9
  33. 20
  34. 72
  35. 40
  36. console.log()
  37. Hi, Arjun!
  38. let
  39. 99
  40. Hello, Kabir!

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