← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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