← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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