← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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