DEV Community

Discussion on: Algorithm 101: 6 Ways to Find the Longest Word in a Sentence

Collapse
 
pamprog profile image
PamProg

Hey !
I don't think you should use map like this. You use it like a forEach, and junior developer could think it's okay to use it like this while it's not :/

Collapse
 
ebereplenty profile image
NJOKU SAMSON EBERE

PamProg thank you for taking your time to read and comment. Can you explain further?

Collapse
 
pamprog profile image
PamProg

Well, your "forEach" and "map" examples are the same, so we could think that both are good to use. But the map (and I'm sure you know it) is used to make a new array, not to find something, filter something or whatever.
It's not because you can do it with map that you should use it and promote it :)

Thread Thread
 
ebereplenty profile image
NJOKU SAMSON EBERE

Thank you. You are awesome 😍