DEV Community

Discussion on: Introduction to Functional Programming

lukaszahradnik profile image
Lukáš Zahradník

Agree, I don't find using map for it to be the best and cleanest (kinda misuse of map to be fair). Your second solution is probably the way to go. I don't know if there are better approaches.

Sometimes it's hard to speculate about performance, because spread, spread and indexOf is probably optimized a lot.