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

Tell us what’s happening:

Your code so far

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

 currentTitle === true ? `${currentTitle} : playingSong.textContent()`;

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 55

I’m not sure what exactly I’m doing wrong with this section.

Please paste all of your code for the setPlayerDisplay function in here using the following method.

To display your code in here you need to wrap it in triple back ticks. On a line by itself type three back ticks. Then on the first line below the three back ticks paste in your code. Then below your code on a new line type three more back ticks. The back tick on my keyboard is in the upper left just above the Tab key and below the Esc key. You may also be able to use Ctrl+e to automatically give you the triple back ticks while you are typing in the this editor and the cursor is on a line by itself. Alternatively, with the cursor on a line by itself, you can use the </> button above the editor to add the triple back ticks.

const setPlayerDisplay = () => {
  const playingSong = document.getElementById("player-song-title");
  const songArtist = document.getElementById("player-song-artist");
  const currentTitle = userData?.currentSong?.title;
  const currentArtist = userData?.currentSong?.artist;
currentTitle === true ? `${currentTitle} : playingSong.textContent()`;

The ternary pattern is:

condition ? exprIfTrue : exprIfFalse

Do you see how you have broken this with the back ticks?

The instructions are asking you to return an empty string if currentTitle is false. Are you doing that?

The instructions are asking you to assign the result to songArtist.textContent. Are you doing that?

I realize now that I hadn’t been with what I had before. I’ve since updated it and its still not working.

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

Your test here is just true, so this is always going to set playingSong.textContent to currentTitle.

I figured it out. Thanks!

1 Like

I have just got this one!

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

I took me one whole day to realize, that “Assign this result to” doesn’t mean I should create a variable… :roll_eyes:

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