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

Tell us what’s happening:

I tried different method such as
currentTitle = playingSong.textContent == true? playingSong.textContent= currentTitle : “”;
currentArtist = songArtist.textContent == true ? songArtist.textContent = currentArtist : “”;
I am confused on what to do next.

Your code so far

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

/* file: styles.css */

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

    currentTitle = playingSong.textContent ? playingSong.textContent= currentTitle : "";
    currentArtist = songArtist.textContent ? songArtist.textContent = currentArtist : "";

// 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 Edg/131.0.0.0

Challenge Information:

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

The question is asked in a confusing way. Here you are setting the textContent to the elements defined in the variables playingSong and SongArtist.

Look at the syntax of how to do that:

One = sign and the variable.textContent goes before the = sign. After the equal sign you are setting the value according to the ternary. If the condition is met, the value is x. If the condition is not met the value is y. Write the ternary according to the correct syntax. There is only 1 equal sign.

I am confused by what you mean by “variable.textContent goes before the = sign.”

Do you mean by this?
playingSong.textContent = currentTitle ? playingSong.textContent == currentTitle : “”;
songArtist.textContent = currentArtist ? songArtist.textContent == currentArtist : “”;

Hi @cybordgeneral

In your original code you had two equals signs in the same line, which is not correct syntax.

Here you are repeating playingSong.textContent and songArtist.textContent

You are correctly assigning the ternary to the .textContent property of the value. However the ternary is not quite right.

Happy coding

Thanks, I get it now.

1 Like