← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. if
  2. 30
  3. 4
  4. alert()
  5. 53
  6. console.log()
  7. 36
  8. for
  9. 58
  10. 28
  11. a pop-up box
  12. 31
  13. let
  14. 8
  15. Welcome, Aman!
  16. <script>
  17. 75
  18. 43
  19. Hi, Riya!
  20. 36
  21. Well done, Zoya!
  22. 60
  23. .js
  24. 1
  25. 25
  26. 121
  27. 11
  28. 91
  29. Well done, Kabir!
  30. 55
  31. Hello, Riya!
  32. actions and changes
  33. let
  34. 42
  35. 23
  36. 79
  37. 45
  38. 54
  39. 52
  40. 89

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