← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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