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

Tell us what’s happening:

I’ve never been this stuck before. Am I missing something simple? I’ve tried this several ways, and nothing has worked.

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 ? playingSong.textContent = true? 'currentTitle' : '';
  currentArtist ? songArtist.textContent = false? 'currentArtist' : ''

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) 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 56

Hi. You’re almost there. The assignment usually happens at the beginning of the line, the ternary operator has to come after the equal sign. Hope this helps!

3 Likes

It looks a little odd if you haven’t seen it before. But I believe you have already written it like this in one of the previous steps.

ele.textContent = condition ? "Assigned to textContent if condition is true" : "Assigned to textContent if condition is false"

As an aside, I think the “implicitly return” part of the challenge text is also a little confusing seeing as you can’t add an explicit return inside the expressions. Well, not unless they are functions which would look pretty weird.

const condition = true;
const result = condition
  ? (() => {
      return "if condition is true";
    })()
  : (() => {
      return "if condition is false";
    })();

console.log(result); // if condition is true
2 Likes

I finally got it. Thank you both for the help! I needed the assignment at the beginning and the way I originally had it at the end. The more I tried changing it, the more I messed it up.

assignment = condition ? trueAction : falseAction;

2 Likes