Build a Music Player - Step 27

Tell us what’s happening:

Can somebody please advise as to how to solve this particular step? Please help. Thanks!

Your code so far

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

/* file: styles.css */

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

const playNextSong = () => {
  if (userData.currentSong === null) {
    playSong(userData.songs[0].id);
  } else {
    playSong(getNextSong())
  }

}

// User Editable Region

Your browser information:

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

Challenge Information:

Build a Music Player - Step 27

try to break down in multiple steps what you need to do

Complete your playNextSong function so that can play the next song in the playlist. 2. If the current song is the last one, 3. set userData.currentSong to null , 2. userData.songCurrentTime to zero 3. and call the pauseSong function

there are 5 statements here:

  1. Complete your playNextSong function so that can play the next song in the playlist.
  2. If the current song is the last one,
    1. set userData.currentSong to null ,
    2. userData.songCurrentTime to zero
    3. and call the pauseSong function

Try one by one, and see where you get stuck

For this

check what playSong takes as argument. Is it a song object?

It takes an id as an argument. So I should I get current song Index and then check if it is the last index?

You get the next song with getSongIndex, but playSong needs the id, you can get the id from the song object

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.