← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. console.log()
  2. if
  3. let
  4. for
  5. Hello, Aman!
  6. .js
  7. 88
  8. <script>
  9. Hi, Aman!
  10. actions and changes
  11. 35
  12. 38
  13. alert()
  14. 25
  15. 56
  16. 12
  17. 15
  18. in the console
  19. let
  20. 2
  21. 26
  22. Well done, Arjun!
  23. 14
  24. 21
  25. Hello, Riya!
  26. 88
  27. 9
  28. Hello, Arjun!
  29. Hello, Riya!
  30. 61
  31. 15
  32. 24
  33. Well done, Kabir!
  34. 62
  35. Well done, Aman!
  36. 40
  37. 3
  38. 33
  39. Welcome, Arjun!
  40. 72

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