← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 1
  2. console.log()
  3. a pop-up box
  4. 48
  5. alert()
  6. for
  7. 53
  8. in the console
  9. <script>
  10. .js
  11. let
  12. 65
  13. 12
  14. Well done, Meera!
  15. 24
  16. 28
  17. 31
  18. 2
  19. Welcome, Arjun!
  20. 46
  21. 34
  22. let
  23. Welcome, Aman!
  24. Hello, Riya!
  25. 14
  26. 56
  27. 23
  28. Welcome, Aman!
  29. Hello, Aman!
  30. 15
  31. 22
  32. 76
  33. Hello, Kabir!
  34. 77
  35. 45
  36. 23
  37. 6
  38. 58
  39. 6
  40. 110

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