PrepAway - Latest Free Exam Questions & Answers

A developer is creating a simple webpage with a button.

A developer is creating a simple webpage with a button. When a user clicks this button for the first time, a message is displayed.

The developer wrote the JavaScript code below, but something is missing. The message gets displayed every time a user clicks the button, instead of just the first time.

null

Which two code lines make this code work as required? (Choose two.)

A. On line 06, add an option called once to button.addEventListener().

B. On line 02, use event.first to test if it is the first execution.

C. On line 04, use event.stopPropagation();

D. On line 04, use button.removeEventListener(‘click’, listen);


Leave a Reply