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

Tell us what’s happening:

Can someone help me that what mistake I have made ?

Your code so far

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

/* file: styles.css */

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

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


// 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

Challenge Information:

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

Why do you have two if statements? I believe the instructions were to write one of those but not both of those.

I did that but still same error shows

please show your updated code

Whole code shall I share or the code I am working?

Please show the new code after removing the extra if statement

const playNextSong = () => {
if(userData?.currentSong === null || userData?.currentSong.id !== song.id){
     const firstSongId = userData.songs[0].id;
}
}

This what i have written and error shows

Sorry, your code does not pass. Try again.

You should create an if statement with the condition userData?.currentSong === null.

Why do you have two statements in your if statement?

Try to read the instructions again. They only wanted you to check one thing.

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').