Learn Modern Javascript Methods by Building Football Team Cards Step-29

Step 29

The next step would be to display the word (Captain) next to the player if they are listed as a captain for the team.

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 return an empty string.

  playerCards.innerHTML += arr.map(
    ({ name, position, number, isCaptain, nickname }) => {
      `
        <div class="player-card">
         /* anwsers section starts */

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

         /* anwsers section starts */
        </div>
      `;
    }
  );

The instructions state:

Have you done that?

1 Like