← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. let
  2. Hi, Kabir!
  3. 10
  4. <script>
  5. for
  6. 36
  7. 48
  8. .js
  9. Hello, Riya!
  10. 61
  11. Well done, Kabir!
  12. 0
  13. alert()
  14. 38
  15. 42
  16. 15
  17. 86
  18. Hi, Aman!
  19. 15
  20. Welcome, Kabir!
  21. 3
  22. 72
  23. 12
  24. in the console
  25. 36
  26. 17
  27. console.log()
  28. 74
  29. 2
  30. 75
  31. 24
  32. 79
  33. 13
  34. actions and changes
  35. 0
  36. Hi, Arjun!
  37. 20
  38. 35
  39. 19
  40. 36

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