← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. alert()
  2. Welcome, Zoya!
  3. 94
  4. 50
  5. 82
  6. console.log()
  7. .js
  8. let
  9. in the console
  10. 132
  11. 24
  12. 52
  13. for
  14. 11
  15. 17
  16. Hi, Arjun!
  17. 7
  18. a pop-up box
  19. actions and changes
  20. Hi, Riya!
  21. let
  22. 70
  23. 25
  24. 1
  25. 110
  26. 64
  27. 48
  28. Hi, Meera!
  29. Hi, Aman!
  30. 3
  31. 57
  32. 18
  33. 49
  34. 16
  35. 44
  36. 4
  37. 65
  38. 48
  39. Well done, Riya!
  40. 87

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