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

Tell us what’s happening:

I’m getting confused on interpreting redefining userData.songs and what ‘implicit return’ means.

The exercise:

Use the filter() method on userData?.songs. Pass in song as the parameter of the arrow function callback and use implicit return to check if song.id is strictly not equal to id. Assign all of that to the userData.songs.

Note: You should not use optional chaining when you assign the result of userData?.songs.filter to userData.songs because the allSongs array will not be undefined or null at that point.

Your code so far

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

/* file: styles.css */

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

const deleteSong = (id) => {
  userData.songs = userData?.songs.filter((song) => {return song.id !== id});
};

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36

Challenge Information:

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

An implicit return means you don’t actually need to add a return statement. It’s a feature of arrow functions, which don’t actually need parentheses.

This is the kind of arrow function the filter callback expects.

(param) => expression