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

Tell us what’s happening:

I think there is something wrong with you checker, the suggested correction is not the right syntax.
playButton.setAttribute(“aria-label”, Play ${song.title});
Is what I am trying to submit but the auto grader is saying that is wrong.

Your code so far

const setPlayButtonAccessibleText = () => {
  const song = userData?.currentSong || userData?.songs[0];
    playButton.setAttribute(
    "aria-label",
    `Play ${song?.title.?}:"Play"`
  );
};

WARNING

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

Challenge Information:

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

Your close, but your mistake is here

The backticks only need to be around the Play ${song.title}. It looks like you have some typos here Play ${song?.title.?}

but also, this is not a correct ternary operator

ternaries use this syntax

condition ? something : something else

you are missing the condition here

In the directions, it tells you to set song?.title to either the current song title or just Play if there is not current song title.

Once you add in the condition to complete your ternary, then the test will pass

2 Likes

Why is the auto coder wanting ?. here song?.title ? and not here Play ${song.title} ?
Is the use of the ?. standard? never knew of it or saw it in use before this tutorial…
Thanks for the assist.

So the challenge wants you to write a ternary.

However this is not a ternary.

ternaries always follow this syntax

the condition here would be song?title

The ? in song?title is known as optional chaining. This allows you to access properties or methods of an object that may be undefined or null without causing an error.

We have to follow the song?title with another ? because that is part of the ternary syntax here

We want to do here is check if we have a song title, If so set the aria label to Play followed by the song title. Otherwise, just set it to the word Play.

song?title ? set the text to the title : set it to just the word Play
2 Likes