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

Tell us what’s happening:

This is my code:

if (song) {
audio.src = song.src;
audio.title = song.title;
} else {
console.log(‘Song not found’);
}

The response that comes back after I check my code says I should set “audio.src” to “song.src”. Not sure where I am going wrong.

Is someone able to tell me where to change my code? Thanking you.

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; 
    } else {
        console.log('Song not found');
    }
};

// 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/127.0.0.0 Safari/537.36 Edg/127.0.0.0

Challenge Information:

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

i’m not sure where this if statement came from?

What about this code:

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

i’m wondering why you keep writing an if statement?

Oh, it is just the response I get on google.

hmm, I don’t know if google knows how to solve this problem.
Try just following the instructions that are given.

Removed it and it worked. Thanks for your help.