← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 16
  2. 72
  3. 46
  4. if
  5. 45
  6. Welcome, Meera!
  7. alert()
  8. <script>
  9. Welcome, Kabir!
  10. 53
  11. for
  12. 24
  13. 80
  14. 26
  15. a pop-up box
  16. 41
  17. 13
  18. 34
  19. 24
  20. 35
  21. console.log()
  22. .js
  23. 19
  24. 18
  25. 81
  26. let
  27. 68
  28. let
  29. Welcome, Meera!
  30. 7
  31. in the console
  32. 82
  33. Hello, Aman!
  34. Welcome, Arjun!
  35. 22
  36. 88
  37. 53
  38. Hi, Zoya!
  39. Hello, Kabir!
  40. 9

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