No need to get upset friend. We are all on the same side here.
Yes, for loops run a bit faster than higher order functions. But the fact is that both solutions are written in O(n) time, and so these micro-optimizations would really only be useful in a specific scenario, but generally (in the literal sense) speaking, both solutions are equally valid.
94
u/c2u5hed Sep 26 '22
Congrats! How about this:
const isPalindrome = (string) => string === [...string].reverse().join('')