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

Tell us what’s happening:

Hi
I didn’t understand why setPlayerCards function was used, In switch case we can assign the values to players card innerHTML using assignment operator in the specific case itself (I have tried that but it didn’t worked don’t know why).
Can some body explain that why this setPlayerCards function was used when we can display inside switch case itself

Your code so far

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

/* file: styles.css */

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




// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36

Challenge Information:

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

Hi there!

function is used for avoiding to repeat the same logic of code again if needed in different cases.

Function reusability is completelu understand but I just want to know that when I do this in switch-case statement
playersCards.innerHTML = players.map((item) => item.position === “defender”
Why nothing is displayed in console , all cards are gone nothing is displayed .i am unable to understand this error

I don’t know why the console is empty, but the functionality is working in preview tab, with that above code or without that code.

By the way, for passing the test you need to defines default clause and call the setPlayersCards function.