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