← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. actions and changes
  2. if
  3. 72
  4. Hello, Arjun!
  5. 70
  6. <script>
  7. 82
  8. in the console
  9. let
  10. 78
  11. 120
  12. for
  13. 18
  14. 71
  15. 36
  16. 68
  17. 14
  18. 14
  19. Hello, Zoya!
  20. 15
  21. 45
  22. 35
  23. 5
  24. 44
  25. 49
  26. Hello, Riya!
  27. 14
  28. 24
  29. 31
  30. let
  31. .js
  32. 3
  33. 17
  34. console.log()
  35. 81
  36. 24
  37. 35
  38. alert()
  39. 2
  40. Hello, Zoya!

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