Build a Music Player - Step 20

Tell us what’s happening:

I am a little confused here.
In the HTML, i am supposed to retrieve the number in the id=“”. This way i can use it to play the song i click on.
I can’t figure out what is happening in here for it to return “null”

Your code so far

<!-- file: index.html -->
<!-- Song looks like this : -->
<li id="song-1" class="playlist-song">
          <button class="playlist-song-info" >
            <span class="playlist-song-title">Can't Stay Down</span>
            <span class="playlist-song-artist">Quincy Larson</span>
            <span class="playlist-song-duration">4:15</span>
          </button>
</li>

/* file: styles.css */

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

songs.forEach((song) => {
  song.addEventListener("click", () => {
    const idreg = /d+/
    const id = song.id.match(idreg) //Tried : song.getAttribute("id").match(idreg) : dosnt work
    //playSong(id)
    console.log(id)
  })
});

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.0

Challenge Information:

Build a Music Player - Step 20

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/workshop-music-player/67594f37fa0c684835f1b064.md at main · freeCodeCamp/freeCodeCamp · GitHub

hello!

this is matching 1 or more “d” character. if you are trying to use the digit character class, please recheck how it is written from here.

there are also tools like RegExr you could use to verify your regex.

another thing to look out for is, the instructions ask to add an event listener for the click event on each button element which is a child of a song element, not to song directly.