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

Tell us what’s happening:

Step 43
Within the arrow function of the event listener, add an if to check if userData?.currentSong is falsey.

Inside the if block, call the playSong() function with the id of the first song in the userData?.songs array. This will ensure the first song in the playlist is played first.

Here is what I did:
if (userData?.currentSong ===null)
{
playSong(userData?.songs[0]?.id);
}

Error:
You should call the “playSong” function with userData?.songs[0].id inside your “if” block.

What’s wrong?

Your code so far

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

/* file: styles.css */

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

if (userData?.currentSong === null) 
{
    playSong(userData?.songs[0]?.id);
}


// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36

Challenge Information:

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

Hello!

Compare above to what you are supposed to add which is: .songs[0].id

1 Like

It’s bust to talk about how you find the error message confusing and what you’ve tried to fix it!