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

Tell us what’s happening:

hi can anyone explain why i stuck here? i did use return for both if and else. thank you

Your code so far

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

/* file: styles.css */

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

const playPreviousSong = () => {
  if(userData?.currentSong === null){
    return exit;
  }else{
    return const currentSongIndex = getCurrentSongIndex();
  }
};

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) 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 58

Hello there!

You only need one return keyword, the first one. You also do not need the “exit” text, using the return keyword exits your function. Check this article for more about the return keyword.

Return Keyword