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

Tell us what’s happening:

I get an error: Use a ternary operator to check if currentTitle is truthy. If so, implicitly return currentTitle otherwise implicitly return an empty string. Assign this result to playingSong.textContent .

Your code so far

Here is my code so far:

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

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

@nurularifin83

Hey there,

What you wrote is completely fine. I think its an issue to be fixed from the test side.

However to pass this test use the below code which exactly does the same thing as your code, but in a different style(less verbosal way):

Mod edit: removed

Happy Coding :keyboard: !

1 Like

Please do not provide any solution code. It should not be anything someone can copy and paste to pass the challenge. Thanks.

1 Like

@Cody_Biggs

FIne, I won’t do it.

But there is an issue in the test itself. This test imposed a very strict and narrow solution ignoring all other correct approaches. I just gave a different version of the his solution, because he already had one.

Then you can use words such as “remove the strict operator in your code as it is not needed” and continue to describe your suggestion instead of providing the actual code. Thanks

@nurularifin83 In your code you have the strict operator (===) You can remove this as its not needed, and then in place of the word true you can use the word currentTitle and it should get rid of the error you are having

2 Likes

Thank you so much cody, I solved. Sometimes the problem is very simple, but my brain can’t even think like that :face_holding_back_tears:

2 Likes

Hey I tried doing the exact same thing but still my code does notpass the test.

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.