Learn modern Javascript by building Football Team Cards - step 30

Hi so I’m not exactly sure what I’m doing wrong in this section.
“Right next to the ${name} expression, add a new embedded expression. Inside that expression, use a ternary operator to check if isCaptain is true. If so, return (Captain) otherwise returns an empty string.”

Here is my Code so Far:

playerCards.innerHTML += arr.map(
    ({ name, position, number, isCaptain, nickname }) => {
      `
        <div class="player-card">
          <h2>${name}, ${(isCaptain == true) ? " (Captain)" : ""}</h2>,  
          
        </div>
      `;
    }
  );

thank you once again for helping.

please give the link to the step

Learn Modern JavaScript Methods By Building Football Team Cards: Step 30 | freeCodeCamp.org

you should not have a comma after the name, and there shouldn’t be a space before (Captain)

1 Like

it is still giving me the same error of having a ternary operator to check if isCaptain is true

this is how i changed it
<h2>${name} ${(isCaptain == true)?"(Captain)" : ""}</h2>

you still have a space before (Captain), meaning that if isCaptain is true you have two spaces after the name, when you should have only one

an other possibility is that you should have only isCaptain as condition, and not have a comparison, as isCaptain is already a boolean

I’m sorry but I don’t see where my space is before (Captain), but I did change the isCaptain Boolean statement.

<h2>${name} ${(isCaptain)?'(Captain)':''}</h2>

It seems like I just didn’t need the parenthesis around the (isCaptain). Thank you for helping though. because when I submitted after taking out the parenthesis it worked out.

2 Likes

bro this code has given me headache

coding is hard! If you need help I suggest opening your own topic!

its ok boss, am sorry if I offended you in anyway. I just had parenthesis around (isCaptain) too. But thanks

this works:

redacted solution

@parallelofleo ,
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

This step is kinda broken because I see in the player cards that (Captain) is before the name yet it only accepts this as like this:
solution redacted

an issue was created here to update the step so the word captain goes before the name