← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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