Tell us what’s happening:
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. This is the error i encounter , how can i solve this ?
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
audio.addEventListener("ended", () => {
const currentSongIndex = getCurrentSongIndex();
const nextsongExists = currentSongIndex < userData.songs.length - 1 ? true : false;
});
// User Editable Region
/* file: styles.css */
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Challenge Information:
Learn Basic String and Array Methods by Building a Music Player - Step 96