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

Tell us what’s happening:

I entered the below code, i’m not clear about how to set condition for this.
whether currentTitle is truthy? ---- currentTitle !== “” ------ will that check currentTitle is true value

Your code so far

playingSong.textContent = currentTitle ? “currentTitle” : “”;
songArtist.textContent = currentArtist ? “currentArtist” : “”;

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

/* file: styles.css */

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

  playingSong.textContent = currentTitle ? "currentTitle" : "";
  songArtist.textContent = currentArtist ? "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/127.0.0.0 Safari/537.36

Challenge Information:

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

Hi!
You’ve set the conditions correctly (congratulations, it took me longer than I’d like to admit how this ternary operator works:D), you just need to set playingSong.textContent and songArtist.textContent to the values of variables currentTitle and currentArtist (you’ve set those two a few lines earlier), or to empty strings.
Hope that helps!

values of variables currentTitle and currentArtist

those two were constants, used ${currentTitle} did not pass. i don’t know where i miss.

Hi,
it seems that you haven’t undersdand the ternary operator.

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

In your code, you’re assigning the string “currentTitle” to playingSong.textContent not the value of the currentTitle variable.
The ternary operator can be explain like :

variableToAssing = condition ? valueIfTrue : valueIfFalse ;

Maybe the quotes around “I’m true” in the explanations confused you.
Hope this helps.

True- they are constants that you’ve assigned some strings to earlier. You can just assign them to the x.textContent directly:)

1 Like

Thank you! code passed.