← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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