← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. <script>
  2. Hi, Aman!
  3. Hi, Meera!
  4. 49
  5. 55
  6. Hi, Kabir!
  7. alert()
  8. let
  9. console.log()
  10. 12
  11. a pop-up box
  12. if
  13. 58
  14. 33
  15. 7
  16. 1
  17. 31
  18. 11
  19. Welcome, Arjun!
  20. .js
  21. 76
  22. 46
  23. 96
  24. Well done, Meera!
  25. for
  26. let
  27. 72
  28. 71
  29. 18
  30. 15
  31. 21
  32. 37
  33. 7
  34. 82
  35. 12
  36. 21
  37. 48
  38. 44
  39. 60
  40. 35

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