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

Tell us what’s happening:

Hi

This is my code:
const playPreviousSong = () => {

if(userData?.currentSong === null){
return;
}else {
const currentSongIndex = getCurrentSongIndex();
}
};

The response I get when trying to pass my code is that I need to call the “playSong” function with “userData.songs[0].id” inside your “if” block"

Can anyone tell me where I am going wrong please?

Thanking you

Your code so far

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

/* file: styles.css */

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

          const playPreviousSong = () => {
 
  if(userData?.currentSong === null){
    return;
  }else {
    const currentSongIndex = getCurrentSongIndex();
  }
};

// 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/127.0.0.0 Safari/537.36 Edg/127.0.0.0

Challenge Information:

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

Can you please talk a bit about how your code fulfills the instructions?

For example the first line:

const playPreviousSong = () => {

Can you please explain how this relates to one of the lines from the instructions?

I ask because I think it’s important to understand how you are coming up with this code and why it’s going wrong.