← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. in the console
  2. let
  3. 13
  4. actions and changes
  5. .js
  6. 65
  7. 28
  8. console.log()
  9. a pop-up box
  10. 44
  11. 55
  12. Hello, Aman!
  13. 89
  14. alert()
  15. for
  16. 70
  17. if
  18. 8
  19. Hi, Meera!
  20. 43
  21. 57
  22. 17
  23. 38
  24. 28
  25. Hi, Riya!
  26. Well done, Aman!
  27. 73
  28. 70
  29. 48
  30. 88
  31. 60
  32. let
  33. 30
  34. 42
  35. 31
  36. Well done, Meera!
  37. Well done, Kabir!
  38. 66
  39. 22
  40. Well done, Arjun!

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