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

Tell us what’s happening:

Your code so far

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

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

Challenge Information:

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

switch (e.target.value) {
    case "nickname":
setPlayerCards(players.filter(player)=>{
 return player.nickname !== null
    
  
}))
  }

I don’t understand why there are so many parentheses, isn’t it possible to come up with something to prevent this nonsense from happening?

why doesn’t this code work?

Of course, there’s no way to figure it out, but how to write it correctly?

Your filter callback function syntax is not correct. The callback should be inside the parentheses with the parameter.

implicitly return player.nickname

This means no return keyword and no function body block {}.


[1, 2, 3, 4].filter((num) => num % 2 === 0) // [2, 4]
1 Like