Learn Modern JavaScript Methods by Building Football Team Cards - Step 27

Tell us what’s happening:

I attempt to render the "(Captain) " string if isCaptain is true, yet the code does not pass?

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

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region


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


// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0

Challenge Information:

Learn Modern JavaScript Methods by Building Football Team Cards - Step 27

it looks like you have an extra space to the right of the (Captain) and just before the single quote. Try removing that.

1 Like

Thank you! This worked!
But still baffled as I believed that there should be a space between (Captain) and ${name} so that it would render: (Captain) Diego Maradona

1 Like

yeah I’m not sure about that. You can just wait until the end to see if anything explains this.

1 Like

actually there is supposed to be a space as you said but it is supposed to be to the immediate left of the ${name}

1 Like

This is my code and I keep getting the error that a space is required between ‘(Captain)’ and ${name}.

${isCaptain ? '(Captain)' : ''} ${name}

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 Help button located on the challenge. This button only appears if you have tried to submit an answer at least three times.

The 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.

2 Likes