← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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