← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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