← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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