← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 15
  2. in the console
  3. 15
  4. Hello, Kabir!
  5. Hello, Meera!
  6. 72
  7. 42
  8. 20
  9. console.log()
  10. 9
  11. 56
  12. 53
  13. .js
  14. for
  15. 29
  16. 13
  17. Welcome, Meera!
  18. 61
  19. 4
  20. 5
  21. if
  22. 47
  23. alert()
  24. <script>
  25. 85
  26. 4
  27. 69
  28. 12
  29. 99
  30. 54
  31. let
  32. 46
  33. a pop-up box
  34. 3
  35. 37
  36. Well done, Zoya!
  37. Hi, Zoya!
  38. 49
  39. 25
  40. 30

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