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

Tell us what’s happening:

  1. You should use the ternary operator to set the textContent property of playingSong to currentTitle or “”.
    please help know sure how to write this out tried a couple ways

Your code so far

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

/* file: styles.css */

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

  currentTitle = (currentTitle) ? playingSong.textContent : "";
  currentArtist = (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

Challenge Information:

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

The top line looks good to me.
But the bottom one is trying to set the currentArtist to a string containing the songArtist.textContent?

They wanted you to set it to the value in that variable. Not to make that variable a string.

The top looks right but it is still giving me the (2. You should use the ternary operator to set the textContent property of playingSong to currentTitle or "" .) message.
This is my code
currentTitle = (currentTitle) ? playingSong.textContent : “”;
currentArtist = (currentArtist) ? songArtist.textContent : “”;

oh oops, now I see the issue.
You were not meant to set the ‘currentTitle’ or the ‘currentArtist’. Those are the values actually.
The things you were meant to set were the .textContent of the respective variables.

Still dont understand SET tried
(currentTitle) ? playingSong.textContent : “”;
currentArtist = () ? songArtist.textContent : “”;

Tried
playingSong.textContent = () ? currentTitle : “”;
playingSong.textContent = (currentTitle) ? currentTitle : “”;

The left hand side of the assignment is correct now for one of the lines. You need to fix the right hand side. For the truthy condition, just follow the instructions given:

Use a ternary operator to check if currentTitle evaluates to a truthy value.

Edit: the second line of the code you last shared is correct.

playingSong.textContent = (currentTitle) ? currentTitle : “”;
teernay operator is (?) checking if currentTitle is truly
Is not working for me

I understand thank you for the guidance. I love the community here.

1 Like