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

Tell us what’s happening:

Please I need help with this challenge:

You should check if a next song exists comparing userData.songs.length and currentSongIndex and set it to a nextSongExists constant. If the last index of the songs array (userData.songs.length - 1) is bigger than the currentSongIndex that means there is a next song.

Your code so far

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

/* file: styles.css */

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

audio.addEventListener("ended", () => {
 const currentSongIndex = getCurrentSongIndex(); })
 const nextSongExists = 
userData.songs.length -1 > currentSongIndex ? true : false;
})
 


// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Mobile Safari/537.36

Challenge Information:

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

you prematurely closed off the arrow function.
you should erase }) here

Thanks. Having corrected, this is the new response:

You should not modify the existing ended event listener and its content.

can you post your new code?
Also make sure the last line for const nextSongExists is all one line (don’t put a newline in the middle)

This is the new code:
audio.addEventListener(“ended”, () => {
const currentSongIndex = getCurrentSongIndex();
const nextSongExists = userData.songs.length -1 > currentSongIndex ? true : false;
})
Thanks.

this is working for me so I think you better click the reset button as you may have changed something they didn’t expect you to change.
Once you click reset, the 2 lines of code should work.

It worked, thanks for your time.

1 Like