← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

HTML and CSS lesson 25: JavaScript basics · Set 808 · 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 coins = 29;
    coins = coins + 7;
    coins = coins - 29;
    console.log(coins);
  2. 2.⚡ Which tag holds JavaScript in a page? (a) <js> (b) <script> (c) <code> (d) <style>
  3. 3.⚡ Where does console.log() show its output? (a) on the title bar (b) in the address bar (c) in the console (d) on the printer
  4. 4.⚡ What number does this code print?
    let coins = 12;
    coins = coins + 19;
    coins = coins - 4;
    console.log(coins);
  5. 5.⚡ What number does this code print?
    let a = 7;
    let b = 2;
    console.log(a * b);
  6. 6.⚡ What does JavaScript add to a web page? (a) the page title (b) the domain name (c) only colours (d) actions and changes
  7. 7.⚡ Which JavaScript word shows a pop-up box? (a) for (b) if (c) alert() (d) let
  8. 8.⚡ What number does this code print?
    let a = 8;
    let b = 3;
    console.log(a * b);
  9. 9.⚡ Which JavaScript word runs code when true? (a) alert() (b) console.log() (c) for (d) if
  10. 10.⚡ What does alert() show? (a) a picture (b) a pop-up box (c) a table (d) a new tab
  11. 11.⚡ What does this code print? (Look at the quotes!)
    let x = "8";
    let y = 6;
    console.log(x + y);
    (a) Error (b) 86 (c) 14
  12. 12.⚡ What does this code print? (Look at the quotes!)
    let x = "4";
    let y = 1;
    console.log(x + y);
    (a) Error (b) 5 (c) 41
  13. 13.⚡ What number does this code print?
    let a = 5;
    let b = 8;
    console.log(a * b);
  14. 14.⚡ Which JavaScript word makes a new variable? (a) alert() (b) let (c) if (d) for
  15. 15.⚡ What does this code print? (Look at the quotes!)
    let x = "8";
    let y = 1;
    console.log(x + y);
    (a) 9 (b) Error (c) 81
  16. 16.⚡ What number does this code print?
    let runs = 12;
    runs = runs + 19;
    runs = runs - 7;
    console.log(runs);
  17. 17.⚡ What does this code print? (Look at the quotes!)
    let x = "2";
    let y = 9;
    console.log(x + y);
    (a) Error (b) 29 (c) 11
  18. 18.⚡ What number does this code print?
    let a = 9;
    let b = 8;
    console.log(a * b);
  19. 19.⚡ What number does this code print?
    let coins = 17;
    coins = coins + 13;
    coins = coins - 12;
    console.log(coins);
  20. 20.⚡ What does this code show?
    let name = "Kabir";
    alert("Hi, " + name + "!");
    (a) Hi, name! (b) name (c) Hi, Kabir! (d) Kabir
  21. 21.⚡ What does this code print? (Look at the quotes!)
    let x = "7";
    let y = 9;
    console.log(x + y);
    (a) Error (b) 16 (c) 79
  22. 22.⚡ What number does this code print?
    let books = 13;
    books = books + 5;
    books = books - 17;
    console.log(books);
  23. 23.⚡ What does this code print? (Look at the quotes!)
    let x = "4";
    let y = 6;
    console.log(x + y);
    (a) 10 (b) Error (c) 46
  24. 24.⚡ What does this code show?
    let name = "Aman";
    alert("Hi, " + name + "!");
    (a) Aman (b) Hi, name! (c) name (d) Hi, Aman!
  25. 25.⚡ What number does this code print?
    let a = 2;
    let b = 5;
    console.log(a * b);
  26. 26.⚡ What number does this code print?
    let a = 13;
    let b = 8;
    console.log(a + b);
  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 does this code show?
    let name = "Aman";
    alert("Welcome, " + name + "!");
    (a) name (b) Welcome, name! (c) Aman (d) Welcome, Aman!
  29. 29.⚡ What number does this code print?
    let apples = 23;
    apples = apples + 13;
    apples = apples - 13;
    console.log(apples);
  30. 30.⚡ Which JavaScript word repeats code? (a) let (b) console.log() (c) if (d) for
  31. 31.⚡ What number does this code print?
    let a = 20;
    let b = 21;
    console.log(a + b);
  32. 32.⚡ What number does this code print?
    let score = 14;
    score = score + 4;
    score = score - 11;
    console.log(score);
  33. 33.⚡ What number does this code print?
    let a = 6;
    let b = 5;
    console.log(a * b);
  34. 34.⚡ What number does this code print?
    let coins = 12;
    coins = coins + 3;
    coins = coins - 7;
    console.log(coins);
  35. 35.⚡ What number does this code print?
    let apples = 5;
    apples = apples + 7;
    apples = apples - 2;
    console.log(apples);
  36. 36.⚡ What number does this code print?
    let a = 49;
    let b = 16;
    console.log(a + b);
  37. 37.⚡ What number does this code print?
    let a = 12;
    let b = 2;
    console.log(a * b);
  38. 38.⚡ What number does this code print?
    let a = 3;
    let b = 5;
    console.log(a * b);
  39. 39.⚡ What does this code show?
    let name = "Aman";
    console.log("Hi, " + name + "!");
    (a) Hi, name! (b) name (c) Aman (d) Hi, Aman!
  40. 40.⚡ What does this code print? (Look at the quotes!)
    let x = "6";
    let y = 3;
    console.log(x + y);
    (a) 63 (b) Error (c) 9

Answer key

  1. 7
  2. <script>
  3. in the console
  4. 27
  5. 14
  6. actions and changes
  7. alert()
  8. 24
  9. if
  10. a pop-up box
  11. 86
  12. 41
  13. 40
  14. let
  15. 81
  16. 24
  17. 29
  18. 72
  19. 18
  20. Hi, Kabir!
  21. 79
  22. 1
  23. 46
  24. Hi, Aman!
  25. 10
  26. 21
  27. 52
  28. Welcome, Aman!
  29. 23
  30. for
  31. 41
  32. 7
  33. 30
  34. 8
  35. 10
  36. 65
  37. 24
  38. 15
  39. Hi, Aman!
  40. 63

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