I just finished the football team cards project and I couldn’t figure out what the “setPlayerCards” function is supposed to do. Especially the parameter of the map() method and how the template literal is being concatenated.
Can anyone kindly explain to me what this function exactly does in football team cards project?
const setPlayerCards = (arr = players) => {
playerCards.innerHTML += arr
.map(
({ name, position, number, isCaptain, nickname }) =>
`
<div class="player-card">
<h2>${isCaptain ? "(Captain)" : ""} ${name}</h2>
<p>Position: ${position}</p>
<p>Number: ${number}</p>
<p>Nickname: ${nickname !== null ? nickname : "N/A"}</p>
</div>
`
)
.join("");
};