← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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