← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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