← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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