← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. <script>
  2. if
  3. .js
  4. 12
  5. 14
  6. 9
  7. 24
  8. console.log()
  9. 70
  10. 26
  11. 77
  12. 30
  13. 96
  14. alert()
  15. for
  16. 35
  17. 16
  18. 76
  19. Hello, Meera!
  20. 6
  21. let
  22. Hi, Kabir!
  23. let
  24. 61
  25. 15
  26. 1
  27. 52
  28. 29
  29. 98
  30. actions and changes
  31. 18
  32. 97
  33. a pop-up box
  34. 12
  35. 24
  36. 22
  37. 74
  38. Hi, Zoya!
  39. 17
  40. 16

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