← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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