← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 36
  2. 96
  3. 34
  4. 51
  5. 83
  6. 25
  7. 15
  8. 17
  9. a pop-up box
  10. 32
  11. alert()
  12. for
  13. 49
  14. console.log()
  15. 50
  16. .js
  17. 44
  18. Well done, Kabir!
  19. 0
  20. 65
  21. 63
  22. 35
  23. Well done, Aman!
  24. 50
  25. 110
  26. 4
  27. actions and changes
  28. 54
  29. <script>
  30. let
  31. 5
  32. 15
  33. 40
  34. 10
  35. 13
  36. 31
  37. 15
  38. 15
  39. 54
  40. Well done, Zoya!

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