← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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