Last active
November 22, 2015 22:26
-
-
Save dmidlo/5dd35bcf59877e91ae36 to your computer and use it in GitHub Desktop.
This file contains 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 characters
function palindrome(str) { | |
function reverseString(str) { | |
str = ((str.split('')).reverse()).join(''); | |
return str; | |
} | |
if((str.toLowerCase()).replace(/[\W_]/g,'') === | |
(reverseString(str).toLowerCase()).replace(/[\W_]/g,'')) | |
{ | |
return(true); | |
} | |
else | |
{ | |
return(false); | |
} | |
} | |
palindrome("eye"); //true //Output === "eye" | |
palindrome("never odd or even"); //true //Output === "neveroddoreven" | |
palindrome("A man, a plan, a canal. Panama"); //true //Output === "amanaplanacanalpanama" | |
palindrome("0_0 (: /-\ :) 0-0"); //true //Output === "0000" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment