← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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