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

Tell us what’s happening:

I have a feeling inside my heart that my first chunk of code is right:

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

but I am feeling very not confident about the subsequent chunk:

=> (song.id === id)
};

I am feeling lost, my friends. I am getting the error message "Your find method should use strict equality to check if song.id is equal to id. I am pretty sure I have accomplished that, but I am not sure how to connect the parts I am more confident in. Thank 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

Challenge Information:

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

1 Like

remove the parenthesis on the inside of the two outer parenthesis so you end up with
find(song => song.id === id);

The two middle parenthesis are not doing what you think they are doing.

2 Likes

Thank you! It feels great and simultaneously frustrating when I am so close to the solution. The syntax always messes me up.

practice writing arrow functions more.
() => {} is the basic structure.
No curly braces if implicit return is used.
No parenthesis if a single parameter is being defined.
Or just use them both always unless explicitly asked not to.

1 Like