← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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