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

Stuck on this step:

Step 36

Before you start working on playing the next and previous song, you need to get the index of each song in the songs property of userData. Remember this is where you spread in the songs.

Use an arrow syntax to create a getCurrentSongIndex function. Then, using implicit return, use the indexOf() method on userData?.songs, and pass in userData.currentSong.

Calling this function will get you the index of each song.

Here’s what I’m doing, could someone help me out? Thank you!

const getCurrentSongIndex = () => (
  userData?.songs.indexOf(userData.currentSong)
);

Your browser information:

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

Challenge Information:

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

Looks like strict test, after removing ( ) around the userData?.(...) tests pass.

Explaining the solution more. You don’t want the parentheses to start the code. () => "( code here )"

I.G.

const getCurrentSongIndex = () => userData?.songs.indexOf(userData.currentSong)

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.