← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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