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

Tell us what’s happening:

I don’t know where is the mistake

Your code so far

audio.addEventListener("ended", () => {
  const currentSongIndex = getCurrentSongIndex();
  const nextSongExists = currentSongIndex < userData?.songs.length - 1;
  
  if (nextSongExists) {
    const nextSong = userData?.songs[currentSongIndex + 1];
    playSong(nextSong.id);
  } else {
  }
});

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0

Challenge Information:

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

Hey there! Welcome to the forums.

I don’t really think you need that if statement. Because the instructions only ask you to assign currentSongIndex to getCurrentSongIndex and check if the next song exists, and I think that’s where the issue is coming from (plus the if statement that is not needed). To check if a next song exists, you first want to make sure that userData exists, and that the next element is not undefined (that it exists for sure)

I hope this analogy helps.

I don’t know why I don’t find now the white space for coding and I don’t have the “hint” or “reset code” buttons!

Have you tried refreshing your browser? Close the tab completely perhaps and then try to open the challenge again.

Yes but nothing! the next exercise work!

Clear the browser cache and cookies (site data), restart it, and try again.

1 Like

I know this is a bit late, but if the instructions and reset button isn’t showing I bring the step up in another browser and it seems to work. Just in case anyone is having issues with that.

1 Like

I also mistook it for creating if statement. then when I came to forum there is already one similar this existed.

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