Build a Music Player - Step 20

Tell us what’s happening:

The clicking the preview works but the code check doesn’t pass. Why?

Your code so far

<!-- file: index.html -->

/* file: styles.css */

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

songs.forEach((song) => {
  song.addEventListener("click", () => {
    let n = Number(song.getAttribute("id").replace("song-", ""))
    playSong(n);
  })
});


// 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/135.0.0.0 Safari/537.36

Challenge Information:

Build a Music Player - Step 20

Note what elements this variable is targeting. It’s not the button elements:

const songs = document.querySelectorAll(".playlist-song");

So, you need to find the button elements within the .playlist-song elements and add the event listeners directly to buttons, as opposed to adding them to the .playlist-song elements themselves.

Thank You. I did understand it was a button element. I was think click the div like a button.

1 Like