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

Tell us what’s happening:

It’s what I did; darn it! It won’t pass!
Step 37
Inside the playSong function, set the audio.src property equal to song.src. This tells the audio element where to find the audio data for the selected song.

Also, set the audio.title property equal to song.title. This tells the audio element what to display as the title of the song.

Your code so far

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

/* file: styles.css */

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

const playSong = (id) => {
  const song = userData?.songs.find((song) => song.id === id);

     if (song) {
    audio.src = song.src;
  audio.title = song.title;
     }
};

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0

Challenge Information:

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

why’d you add the if statement though?

1 Like

Oh. I think I added it in the last one.

sorry I don’t think I understood you.

Was there something in the instructions that you needed help understanding or are you okay now?

I do everything in Codeio first. Then I copy it over to Freecodecamp. I copied the if statement by mistake. LOL