← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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