← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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