Https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-basic-string-and-array-methods-by-building-a-music-player/step-48

i do all the task ask but keeps going wrong…

 if (userData?.currentSong === null) {
    playSong(userData?.songs[0].id);
  else {
  currentSongIndex = getCurrentSongIndex()  
  }
  }

that’s it ! the exercise tells " Add an else block to the if" and not After the IF
ow man. why do they ask to add to the and not after the?
i’m so much literal that i strugle with this details

Your else block is correct and I think your mistake is related to a different topic. Generally, I’m trying to find errors in these steps:

  • Did I write the correct variable name?
  • Where does that variable come from?
  • Did I call the function correctly?
  • What was that function?
  • Did I use semicolons or operators correctly?

Because at the end of the day, making a mistake is inevitable. The real challenge is how to manage it…

no…the correct else was when i put the else ouside the if.
the excercise asked to put in the IF thats why i was doing wrong :frowning:

1 Like

because an else can’t exist without an if. If you have an if: if () {}, there is only one way to add an else, if () {} else {}

1 Like

Okay after that still one more thing wrong on there. If you found it too, great.

1 Like

yes, a else after an if and not in the IF
thanks Ilenia im too literal so i sufer a lot