← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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