← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 82
  2. 41
  3. 1
  4. 37
  5. 24
  6. for
  7. let
  8. console.log()
  9. alert()
  10. Well done, Meera!
  11. 29
  12. 88
  13. 26
  14. .js
  15. a pop-up box
  16. 64
  17. 43
  18. 20
  19. 10
  20. Hello, Riya!
  21. Hi, Riya!
  22. Well done, Arjun!
  23. 15
  24. 0
  25. 34
  26. 81
  27. 8
  28. 7
  29. Hi, Meera!
  30. actions and changes
  31. 11
  32. if
  33. 132
  34. 68
  35. 36
  36. 79
  37. 22
  38. Hello, Zoya!
  39. 59
  40. 55

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