← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. Well done, Riya!
  2. <script>
  3. 47
  4. in the console
  5. console.log()
  6. 19
  7. actions and changes
  8. 81
  9. a pop-up box
  10. alert()
  11. .js
  12. 50
  13. for
  14. 20
  15. 16
  16. 13
  17. 14
  18. 83
  19. 25
  20. Hello, Riya!
  21. 17
  22. 16
  23. 18
  24. 11
  25. Hi, Meera!
  26. 70
  27. 34
  28. 77
  29. let
  30. 79
  31. Hi, Kabir!
  32. 63
  33. 3
  34. Well done, Meera!
  35. 20
  36. 25
  37. 38
  38. 29
  39. 27
  40. 144

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