Build a Music Player - Step 13

Tell us what’s happening:

Sorry, your code does not pass. Hang in there.

Your playSong function should set the currentTime property of the audio object to 0 when no current song is playing.

Your code so far

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

/* file: styles.css */

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

  function playSong(songId) {
  const song = userData.songs.find(s => s.id === songId);

  if (song) {
    // Reset playback time only if no song is currently playing
    if (!userData.currentSong) {
      audio.currentTime = 0;
    }

    userData.currentSong = song;
    userData.songCurrentTime = 0;
    audio.src = song.src;
    audio.title = song.title;
    audio.play();
  }
}


// User Editable Region

Your browser information:

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

Challenge Information:

Build a Music Player - Step 13
https://www.freecodecamp.org/learn/full-stack-developer/workshop-music-player/step-13

Hi @vaibhaviboche

It looks like you changed the playSong variable from an arrow function to a regular function.

Try resetting the step and only adding the code you are asked, without modify the other parts of the code.

If you are still having problems, please post your full code.

Here are some instructions:

When you enter a code, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Happy coding