← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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