← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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