Learn Basic String and Array Methods by Building a Music Player - Step 42

Tell us what’s happening:

This step and the previous step have been difficult. I used Chatgpt and copied paste the answer because I do not know what ought to be done. I don’t want to copy answers from AI. I am confused about what is required in this step

Your code so far

addEventListener("click") => {} 
<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

addEventListener("click") => {} 


// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36

Challenge Information:

Learn Basic String and Array Methods by Building a Music Player - Step 42

step back, what is the syntax for the addEventListener? if you don’t remember it, you can google this

Hi @camaguncoso

image

The red underline indicates a syntax error.

Also, something is missing from the code.

You should call the addEventListener() method on your playButton variable.

Happy coding

1 Like

Syntax is not correct. For any element, the syntax for event listener will be:

element.addEventListener("eventName", () => {
      // Logic goes here.
})

The eventName is the event for which you want to do something in your code. The second parament is the callback function which is a normal function which will execute when the event is happened. In your case the event is click.

Thank you very much. This actually helped a lot