← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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