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

Tell us what’s happening:

Here is my code js about setPlayButtonAccessibleText function:

const setPlayButtonAccessibleText = () => {
  const song = userData?.currentSong;

I have tried to create a song constant and set it to the current song of userData , or the first song in the userData?.songs array, but it was error although I tried to creates the song constant, retrieving either the currently playing song or the first song in the playlist, using optional chaining:

const song = userData?.currentSong ?? userData?.songs[0];

Here is my screenshot:

Can someone help to fix this error?

### Your code so far


The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

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

Challenge Information:

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

Have you learned to use ternary statements? The format is below. The step doesn’t tell you to use one directly, but is exactly what is needed to pass, and makes sense from a software engineering standpoint.

const song = condition ? what to do for true : what to do for false;

Did you get any clue to solve the issue I am stuck on this issue?

you have to use the OR operator(||)

1 Like