← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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