← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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