Learn Basic String and Array Methods by Building a Music Player Step 74, Ternary Syntax for Label Attributes

I’ve found the solution via looking at the forums, but I had originally had the following as my code for my ternary operator. Could someone explain to me why the equal sign use here is not correct?

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

You should search for the correct syntax for .setAttribute()

1 Like

wowie, thank you :heart_hands:

1 Like

in general, you can’t assign a value to a strings, strings are not made like that