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

Tell us what’s happening:

What is going on in my code? i check if currenttitle is true, then assign playingsongtextcontent to current title and if not i set it to “”, for me seens like i dont have where to store it or misstore it somewhere?

Your code so far

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

/* file: styles.css */

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

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

// 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/128.0.0.0 Safari/537.36 OPR/114.0.0.0

Challenge Information:

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

i guess this one is closer to the solution but still confused why not
currentTitle ? playingSong.textContent = currentTitle : currentTitle = “”;

Hi there!

You should begun the both lines of code with .textContent on the variable.

You should not use the .textContent property after ternary condition ?

why cant i do the way i did?
currentTitle.textContent ? playingSong = currentTitle : playingSong = “”;
currentArtist.textContent ? songArtist = currentArtist : songArtist = “”;
Like this?
currentTitle.textContent ? playingSong.textContent = currentTitle : playingSong.textContent = “”;
currentArtist.textContent ? songArtist.textContent = currentArtist : songArtist.textContent = “”;
Or this?

currentTitle and currentArtist should be use as the ternary condition. Variables playing song and songArtist should be used with the .textContent at beginning.

.textContent property should be used only one’s within both lines of code with the variables at the beginning of the both lines of code

currentTitle.textContent ? playingSong = currentTitle : playingSong = “”;
currentArtist.textContent ? songArtist = currentArtist : songArtist = “”;
if u mean this way, it doesnt pass

I said, You should use the variables playingSong and songArtist with the .textContent

Assignment after ternary condition isn’t correct. Follow the example given in the challenge instructions.

playingSong.textContent = currentTitle ? currentTitle : “”;?
So i should say what will be with smth if , then condition, and true or false then?
So in this case smth will be textcontent of playing song then condition of currenttitle and if yes then it is as it is and if not then “”

Yes. That’s it. Both lines should be the same as that one.

1 Like

Thank you for help
:cowboy_hat_face:

1 Like

It’s my pleasure. Happy Coding.

1 Like