← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 20
  2. 16
  3. 25
  4. a pop-up box
  5. 21
  6. 2
  7. 33
  8. for
  9. 54
  10. 54
  11. 1
  12. 27
  13. 49
  14. Hello, Kabir!
  15. 81
  16. 9
  17. 1
  18. console.log()
  19. actions and changes
  20. .js
  21. Welcome, Kabir!
  22. 32
  23. Well done, Zoya!
  24. 21
  25. 33
  26. 21
  27. 63
  28. Well done, Meera!
  29. 84
  30. 21
  31. 46
  32. alert()
  33. Welcome, Aman!
  34. 18
  35. 76
  36. Hi, Kabir!
  37. 15
  38. 25
  39. 33
  40. 0

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