← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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