← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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