← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 132
  2. alert()
  3. 32
  4. Hi, Meera!
  5. if
  6. actions and changes
  7. 18
  8. let
  9. let
  10. 23
  11. 20
  12. 24
  13. in the console
  14. for
  15. console.log()
  16. 76
  17. 2
  18. 44
  19. Hi, Kabir!
  20. Hello, Arjun!
  21. 61
  22. 8
  23. Well done, Riya!
  24. Welcome, Aman!
  25. Hi, Zoya!
  26. 16
  27. 93
  28. 55
  29. 62
  30. 17
  31. 5
  32. Hello, Kabir!
  33. Hello, Arjun!
  34. 2
  35. 13
  36. Hello, Zoya!
  37. 5
  38. 74
  39. .js
  40. 108

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