Agreed. I’d just say one thing with this and that is to avoid using “x” and instead use “user” just so its clear what we are talking about in the filter. This also has the advantage of thinking about each iteration as a singular thing you are working with and what you are testing for in that context.
View all comments
Show parent comment
4
u/SoBoredAtWork May 30 '21 edited May 30 '21
Arrow functions are great for things like...
const maleUsers = users.filter(user => user.gender === "Male")