Tell us what’s happening:
so in this step 35, it’s asking me for: If you press the previous button when no song is playing, the first song will play. To fix this, add an if statement at the beginning of the playPreviousSong function. Check if the current song is null and stop the function execution with a return statement. so i did: const playPreviousSong = () => {
if (userData.currentSong === null) {
return;
} and still doesn’t work, i dont know what else can i do
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const playPreviousSong = () => {
if (userData.currentSong === null) {
return;
}
const previousSong = getPreviousSong();
if (previousSong) {
playSong(previousSong.id);
} else {
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/149.0.0.0 Safari/537.36
Challenge Information:
Build a Music Player - Step 35