Last active
December 10, 2015 12:52
-
-
Save Stoffo/38f8b64ee5b877a6a7da to your computer and use it in GitHub Desktop.
Revisions
-
Stoffo revised this gist
Dec 10, 2015 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ function palindrome(str) { // Convert to lower case and replace everything what's not a letter or a number. var x = str.toLowerCase().replace(/[^a-z0-9]/g, ''); //convert string to array, turn it around and put it back together an match it against filtered string: return x.split('').reverse().join('') === x; } -
Stoffo created this gist
Dec 10, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ function palindrome(str) { var x = str.toLowerCase().replace(/[^a-z0-9]/g, ''); return x.split('').reverse().join('') === x; } palindrome("eye"); /* palindrome("eye") should return a boolean. palindrome("eye") should return true. palindrome("race car") should return true. palindrome("not a palindrome") should return false. palindrome("A man, a plan, a canal. Panama") should return true. palindrome("never odd or even") should return true. palindrome("nope") should return false. palindrome("almostomla") should return false. palindrome("My age is 0, 0 si ega ym.") should return true. palindrome("1 eye for of 1 eye.") should return false. palindrome("0_0 (: /-\ :) 0-0") should return true. */