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

Tell us what’s happening:

I am unable to understand the step 61, I tried multiple things. Lemme know where i am making a mistake. Thanks in advance.

Your code so far

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

Error Message:

Sorry, your code does not pass. Don't give up.
You should use the `ternary` operator to set the `textContent` property of `playingSong` to `currentTitle` or `""`. ```

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) 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 61

It helps if you can copy and paste the instructions for that step :innocent:

Sorry my bad. Here’s the instruction :

Step 61

textContent sets the text of a node and allows you to set or retrieve the text content of an HTML element.

<div id="example">This is some text content</div>
const element = document.getElementById('example');
console.log(element.textContent); // Output: This is some text content

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.

Then, use a ternary operator to check if currentArtist is truthy. If so, implicitly return currentArtist otherwise implicitly return an empty string. Assign this result to songArtist.textContent.

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Hi @Holla !

Welcome to the forum!

It looks like you have some incorrect syntax

The directions want you to update the text content.

Here is how to use the textContent property

someElement.textContent = someValueGoesHere

The left side of the assignment operator here should be to update the text content for the currentTitle

Once you fix that, then you need to fix the ternary.

It looks like you go this right

but the rest following it is incorrect.

The lesson wants you to set currentTitle otherwise set an empty string

once you fix that, then you will do the same thing for the songArtist.textContent .

hope that helps

Ah! So implicit means use quotes, like you did in the falsey part of the ternary(Also I don’t know the correct spelling of falsey? falsy?).

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

If this helps, click on the solution icon below this post, it helps other ppl know you figured it out, k?

Thanks a bunch. I figured it out. The property comes first, then the ternary operator for variable.
Thanks Again for Quick Responses. Really appreciate it.

Thank You for your quick responses. I figured it out. My statement was incorrect. I needed to put the value of property first and then ternary operator.
Thanks a bunch.

Yeah, she’s quick and very knowledgeable, I’m just trying to do my ‘rubber duck’ explanations to remember things myself, lol!

I have also created an issue for this step since the wording shouldn’t mention implicit return.
It would be better to say this instead

if `currentTitle` evaluates to a truthy value set `playingSong.textContent` to `currentTitle` otherwise, set it to an empty string.
3 Likes

This is the best explanation ever. My brain is so tiny that even I could not read properly this simply requests such as
’ Assign this result to songArtist.textContent .
and i started messing with it. instead asign to it
songArtist.textContent = then code here
Thank you so much for your explanation
Thanks a million :wink: