← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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