← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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