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

Tell us what’s happening:

What’s wrong with this answer. It seems to be what the question is asking…

Your code so far

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

/* file: styles.css */

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

const setPlayButtonAccessibleText = () => {
  const song = userData?.songs ? "userData[0]" || "userData?.songs[1]" 
};

// 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/131.0.0.0 Safari/537.36

Challenge Information:

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

use the OR operator (|| )

you have some kind of broken ternary. Remove the part userData?.songs ?

then

to set it to the current song of userData , or the first song in the userData?.songs array.

is "userData[0]" the current song of userData or is it a string that is literally "userData[0]"?

So you’re insinuating this?:

const setPlayButtonAccessibleText = () => {
  const song = userData[0] || "userData?.songs[1]" 
};

warmer, but

is userData an array?

I did not say anything about this but you should apply same thing as the other side

so like this?

const setPlayButtonAccessibleText = () => {
  const song = userData || "userData?.songs" 
};

what value are you asked to give to song? is that the whole of userData? or just a song?

Hi there!

You need to learn that, when or where to use quote marks within your code.

the whole of userData?

please read the instructions

set it to the current song of userData , or the first song in the userData?.songs array.

“the current song of userData” is not the whole of userData. Look above at the shape of userData.
the other is “the first song in the userData?.songs array”

That’s why I put userData[0]

does userData have a property 0? scroll up to see how userData is

current song is null

it can be null, true, that’s why there are two options with the OR operator. It’s not always null because other code changes tbe value of the property.
You need to write the code to access that value tho

What is wrong with this code? Should it not be in an array as requested?

const setPlayButtonAccessibleText = () => {
  const song = [userData?.currentSong || userData?.songs[0]];
};

@ILM @hasanzaib1389

Read the instructions carefully:
create a song constant and use the OR operator (||) to set it to the current song of userData, or the first song in the userData?.songs array.

It’s aren’t asked to add the required values within an array []. Because it’s already in an array within an object called userData on line number 82.