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

Tell us what’s happening:

Before playing the song, you need to make sure it starts from the beginning. This can be achieved by the use of the currentTime property of the audio object.

Add an if statement to check whether the userData?.currentSong is null or if userData?.currentSong.id is strictly not equal song.id. Inside if block, set the currentTime property of the audio object to 0.

I’m stuck at this step and can’t figure it out.

Your code so far

if(userData?.currentSong = null || userData?.currentSong.id !== song.id){
  audio.currentTime = 0
}

Console log:

SyntaxError: unknown: Support for the experimental syntax 'optionalChainingAssign' isn't currently enabled (93:4):

  91 |   audio.title = song.title;
  92 |
> 93 | if(userData?.currentSong = null || userData?.currentSong.id !== song.id){
     |    ^
  94 |   audio.currentTime = 0
  95 | }
  96 | };

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0

Challenge Information:

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

That error looks scary indeed, and it started to fool me too.

Take a look at the first part of the condition - userData?.currentSong = null, that’s not a comparison.

4 Likes

lol thank you forgot about comparison :sweat_smile:

1 Like