update palindrome snippet

This commit is contained in:
Stefan Feješ
2018-04-26 19:20:41 +02:00
parent dcd59b7bb9
commit ee2bba8ef2

View File

@ -8,13 +8,7 @@ Then, `String.split('')` into individual characters, `Array.reverse()`, `String.
```js ```js
const palindrome = str => { const palindrome = str => {
const s = str.toLowerCase().replace(/[\W_]/g, ''); const s = str.toLowerCase().replace(/[\W_]/g, '');
return ( return s === [...s].reverse().join('');
s ===
s
.split('')
.reverse()
.join('')
);
}; };
``` ```