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

Tell us what’s happening:

This is my code:
const song = userData?.songs?.find(song => song.id === id);

For some reason, I am not having much success with answering this question.

Apparently I need to use the “find” method on “userData?.songs.”

Can someone please tell where I am going wrong?

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);

};

// 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 36

the test doesn’t expect you to use ?. to call find I’m guessing.
Just use regular dot notation when calling methods.

Thank you so much it worked.

1 Like