JavaScript Simplified / Chapter 65 Exercises

  • Index of exercises
  • Email me

1

2

3

4

5

6

7

8

9

10

Congratulations. You've aced all the exercises for this chapter.


To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.


Are you ready to rate JavaScript Simplified? on Amazon?


Rate it on Amazon.

0,1,2,3,4,5,6,7,8,9

0

0

0

0

This event listener calls the function when the user clicks anywhere on the document. document.addEventListener(______, greetUser); "click" •click•
Type the two incorrect characters in this statement. document.addEventListener("click", greetUser()); () \(\)
When the user clicks anywhere on the document, this function is triggered. Code the event listener. function youClicked() {
  alert("You clicked");
}
document.addEventListener("click", youClicked); document\.addEventListener\(•click•,youClicked\);
When the user clicks anywhere on the document, the function is called. Fill in the blank. _________("click", greetUser); document.addEventListener document\.addEventListener
Code an event listener that calls the function addNumbers() when the user clicks anywhere on the document. document.addEventListener("click", addNumbers); document\.addEventListener\(•click•,addNumbers\);
Code an event listener that calls a function when the user clicks anywhere on the document. Make up the function name. document.addEventListener("click", someFunction); document\.addEventListener\(•click•,.*\);
When an event listener is listening for a double click, the first argument inside the parentheses is "dblclick". Code an event listener that listens for a double click anywhere on the document. Make up the function name. document.addEventListener("dblclick", someFunction); document\.addEventListener\(•dblclick•,.*\);
Using an arrow function, code an event listener that displays "Hi" in an alert when the user clicks anywhere on the document. document.addEventListener("click", () => {
  alert("Hi");
});
document\.addEventListener\(•click•,\(\)=>{[\r\n]?alert\(•Hi•\);[\r\n]?}\);
  1. I've coded a function. Below my code, code an event listener that calls the function when the user clicks anywhere on the document.
  2. After writing your code, click the Result button. The panel under the Result button will turn white.
  3. Click anywhere in the white panel.
  4. If you've coded correctly, the greeting will appear in the white panel.
  5. For help with this code, see Chapter 65 in the book.
  1. Code an event listener using an arrow function:
  2. A message is displayed in an alert when the user clicks anywhere on the document.
  3. After writing your code, click the Result button. The panel under the Result button will turn white.
  4. Click anywhere in the white panel.
  5. Wait a moment.
  6. If you've coded correctly, an alert will display the message.
  7. For help with this code, see Chapter 65 in the book.