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

Tell us what’s happening:

I can’t seem to figure this one out can someone please help it has been over 3 hours now and I read all the comments from previous people that asked but still nothing seems to work

Your code so far

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

/* file: styles.css */

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

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

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0

Challenge Information:

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

Use a ternary operator to check if currentTitle evaluates to a truthy value. If it does, set playingSong.textContent to currentTitle . Otherwise, set it to an empty string.

how are you setting a value to playSond.textContent?

Check if ‘playingSong.textContent’ matches the ‘currentTitle’ (equality).
If it does, set playingSong.textContent to currentTitle . Otherwise, set it to an empty string.

Use the same approach for the second part of the challenge.

1 Like

Hi there!
Where is the assignment and condition for ternary operator, before ?

1 Like

I feel so dumb what must I assign?
Here is my update version.
playingSong.textContent === currentTitle ? playingSong.textContent = currentTitle : playingSong.textContent = “”;

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

};

I don’t know what I am doing wrong here is my latest version:

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

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

};

don’t put the assignment inside the ternary, instead make the ternary be on the right of the assignment operator

also read carefully because .textContent is not what you should have as the condition of the ternary

1 Like

Analyze your code in the first post:

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

the condition should be on the left side of the question mark (as you did in the last post), and if the condition is evaluated to a truthy value playingSong.textContent will be set to currentTitle(as it is already given here in the code as the first value after the question mark), else it will be an empty string “” (the value after the colon).
Apply the same approach for the second part of the challenge.

1 Like

Thank you so much , english is not my mother tongue so the whole assignment thing has been crazy to me. thank you.

1 Like

Thank you so much , english is not my mother tongue so the whole “assignment” thing has been crazy to me. thank you.

Thank you so much , english is not my mother tongue so the whole assignment wording thing has been crazy to me. thank you.

I still don’t understand why can’t we use the === or == operators to check for the truthy value instead we assign the value on the left to the currentTitle but I kind of get it now but yeah I guess I need to cry before figuring it out.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.