← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. if
  2. 20
  3. 20
  4. 19
  5. let
  6. actions and changes
  7. 110
  8. 6
  9. Welcome, Aman!
  10. .js
  11. alert()
  12. console.log()
  13. a pop-up box
  14. let
  15. 23
  16. 19
  17. 72
  18. 9
  19. 45
  20. 11
  21. 50
  22. in the console
  23. 23
  24. 15
  25. 35
  26. Well done, Meera!
  27. 6
  28. 21
  29. 8
  30. 44
  31. 25
  32. Well done, Kabir!
  33. Hello, Kabir!
  34. 16
  35. 58
  36. for
  37. Hello, Arjun!
  38. 51
  39. Hi, Kabir!
  40. Well done, Aman!

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