← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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