My code is unable to be executed; clicking the button does nothing. Usually that means that there’s some sort of syntax error the machine doesn’t detect, but I can’t figure out what it is.
Instructions: Add an if
statement to check whether the userData?.currentSong
is falsy OR if userData?.currentSong.id
is strictly not equal song.id
. This condition will check if no current song is playing or if the current song is different from the one that is about to be played.
Inside if
block, set the currentTime
property of the audio
object to 0
.
if(!userData?.currentSong || userData?.currentSong.id !== song.id) {
audio.currentTime = 0;
}