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

I just don’t get it.

Step 20

Now you need to call the renderSongs function and pass in userData?.songs in order to finally display the songs in the UI.

Optional chaining (?.) helps prevent errors when accessing nested properties that might be null or undefined. For example:

const user = {
  name: "Quincy",
  address: {
    city: "San Francisco",
    state: "CA",
    country: "USA",
  },
};

// Accessing nested properties without optional chaining
const state = user.address.state; // CA

// Accessing a non-existent nested property with optional chaining
const zipCode = user.address?.zipCode; // Returns undefined instead of throwing an error

Call the renderSongs function with the songs property of userData. This will render the songs in the playlist.

renderSongs(userData?.songs);

Your browser information:

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

Challenge Information:

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

Hello, delgado,

I think you’ll need to specify a little more which part of the challenge you don’t understand so that others are able to help you.

renderSongs(userData?.songs); worked for me (i.e. the song list did display after this).