DEV Community

Discussion on: Palindrome String in Javascript

Collapse
 
neradev profile image
Moritz Schramm

I think this is way easier:

const isPalindrome = (s) => s.split('').reverse().join('') === s;
Collapse
 
provish profile image
Vishal Gupta

Sure, it is less code, but each function split, reverse, join will be executing a traversal, which will be 3 loops.

While it can be achieved in a single loop.