← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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