Skip to content

Commit

Permalink
Merge pull request Chalarangelo#25 from meetzaveri/patch-1
Browse files Browse the repository at this point in the history
Create Check_for_palindrome.md
  • Loading branch information
Chalarangelo authored Dec 12, 2017
2 parents f322325 + 64928ed commit eb0d04c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions snippets/Check_for_palindrome.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Check for palindrome

Convert string `toLowerCase()` and use `replace()` to remove non-alphanumeric characters from it.
Then, `split('')` into individual characters, `reverse()`, `join('')` and compare to the original, unreversed string, after converting it `tolowerCase()`.

```
palindrome = str => (str.toLowerCase().replace(/[\W_]/g,'').split('').reverse().join('')==str.toLowerCase().replace(/[\W_]/g,''));
```

0 comments on commit eb0d04c

Please sign in to comment.