← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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