← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

HTML and CSS lesson 25: JavaScript basics · Set 852 · 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 books = 13;
    books = books + 7;
    books = books - 10;
    console.log(books);
  2. 2.⚡ What does this code show?
    let name = "Zoya";
    console.log("Well done, " + name + "!");
    (a) Well done, name! (b) Zoya (c) Well done, Zoya! (d) name
  3. 3.⚡ Which word makes a new variable? (a) let (b) make (c) put (d) give
  4. 4.⚡ Which JavaScript word writes in the console? (a) if (b) console.log() (c) let (d) for
  5. 5.⚡ Which JavaScript word repeats code? (a) if (b) console.log() (c) for (d) let
  6. 6.⚡ What number does this code print?
    let a = 7;
    let b = 14;
    console.log(a + b);
  7. 7.⚡ Which JavaScript word runs code when true? (a) let (b) console.log() (c) alert() (d) if
  8. 8.⚡ Which tag holds JavaScript in a page? (a) <js> (b) <script> (c) <style> (d) <code>
  9. 9.⚡ What does this code print? (Look at the quotes!)
    let x = "5";
    let y = 8;
    console.log(x + y);
    (a) 13 (b) 58 (c) Error
  10. 10.⚡ What number does this code print?
    let a = 6;
    let b = 6;
    console.log(a * b);
  11. 11.⚡ What number does this code print?
    let score = 20;
    score = score + 14;
    score = score - 22;
    console.log(score);
  12. 12.⚡ Where does console.log() show its output? (a) in the address bar (b) in the console (c) on the title bar (d) on the printer
  13. 13.⚡ What number does this code print?
    let a = 58;
    let b = 34;
    console.log(a - b);
  14. 14.⚡ What number does this code print?
    let coins = 10;
    coins = coins + 18;
    coins = coins - 20;
    console.log(coins);
  15. 15.⚡ What does this code show?
    let name = "Arjun";
    console.log("Well done, " + name + "!");
    (a) Well done, name! (b) name (c) Arjun (d) Well done, Arjun!
  16. 16.⚡ What does this code show?
    let name = "Aman";
    alert("Hi, " + name + "!");
    (a) Hi, name! (b) Aman (c) name (d) Hi, Aman!
  17. 17.⚡ What number does this code print?
    let a = 44;
    let b = 1;
    console.log(a + b);
  18. 18.⚡ What does this code print? (Look at the quotes!)
    let x = "7";
    let y = 9;
    console.log(x + y);
    (a) Error (b) 79 (c) 16
  19. 19.⚡ What does this code show?
    let name = "Aman";
    console.log("Well done, " + name + "!");
    (a) Well done, name! (b) name (c) Well done, Aman! (d) Aman
  20. 20.⚡ What does this code show?
    let name = "Arjun";
    alert("Welcome, " + name + "!");
    (a) Arjun (b) name (c) Welcome, name! (d) Welcome, Arjun!
  21. 21.⚡ 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
  22. 22.⚡ What number does this code print?
    let a = 18;
    let b = 7;
    console.log(a + b);
  23. 23.⚡ What number does this code print?
    let coins = 5;
    coins = coins + 3;
    coins = coins - 8;
    console.log(coins);
  24. 24.⚡ What number does this code print?
    let marks = 29;
    marks = marks + 9;
    marks = marks - 15;
    console.log(marks);
  25. 25.⚡ What does this code print? (Look at the quotes!)
    let x = "3";
    let y = 6;
    console.log(x + y);
    (a) Error (b) 9 (c) 36
  26. 26.⚡ What number does this code print?
    let a = 8;
    let b = 10;
    console.log(a * b);
  27. 27.⚡ What does this code show?
    let name = "Riya";
    console.log("Hi, " + name + "!");
    (a) Hi, name! (b) Hi, Riya! (c) name (d) Riya
  28. 28.⚡ What does alert() show? (a) a new tab (b) a pop-up box (c) a picture (d) a table
  29. 29.⚡ What number does this code print?
    let a = 54;
    let b = 25;
    console.log(a + b);
  30. 30.⚡ What number does this code print?
    let a = 58;
    let b = 4;
    console.log(a + b);
  31. 31.⚡ Which JavaScript word shows a pop-up box? (a) let (b) alert() (c) for (d) console.log()
  32. 32.⚡ What number does this code print?
    let a = 4;
    let b = 5;
    console.log(a * b);
  33. 33.⚡ Which JavaScript word makes a new variable? (a) alert() (b) for (c) if (d) let
  34. 34.⚡ What does this code print? (Look at the quotes!)
    let x = "3";
    let y = 3;
    console.log(x + y);
    (a) 33 (b) Error (c) 6
  35. 35.⚡ What number does this code print?
    let a = 3;
    let b = 6;
    console.log(a * b);
  36. 36.⚡ What number does this code print?
    let apples = 24;
    apples = apples + 18;
    apples = apples - 3;
    console.log(apples);
  37. 37.⚡ What number does this code print?
    let runs = 5;
    runs = runs + 3;
    runs = runs - 2;
    console.log(runs);
  38. 38.⚡ What does this code print? (Look at the quotes!)
    let x = "8";
    let y = 8;
    console.log(x + y);
    (a) Error (b) 16 (c) 88
  39. 39.⚡ What number does this code print?
    let a = 5;
    let b = 6;
    console.log(a * b);
  40. 40.⚡ What does this code print? (Look at the quotes!)
    let x = "2";
    let y = 5;
    console.log(x + y);
    (a) Error (b) 7 (c) 25

Answer key

  1. 10
  2. Well done, Zoya!
  3. let
  4. console.log()
  5. for
  6. 21
  7. if
  8. <script>
  9. 58
  10. 36
  11. 12
  12. in the console
  13. 24
  14. 8
  15. Well done, Arjun!
  16. Hi, Aman!
  17. 45
  18. 79
  19. Well done, Aman!
  20. Welcome, Arjun!
  21. 29
  22. 25
  23. 0
  24. 23
  25. 36
  26. 80
  27. Hi, Riya!
  28. a pop-up box
  29. 79
  30. 62
  31. alert()
  32. 20
  33. let
  34. 33
  35. 18
  36. 39
  37. 6
  38. 88
  39. 30
  40. 25

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