← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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