Created
April 2, 2019 16:11
-
-
Save bmansk8/d792805b1181581d6f64b7a5ee9c75f9 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) { | |
var cleanUp = str.replace(/([^a-z0-9]+)/gi , '').toLowerCase(); | |
var og=str.replace(/([^a-z0-9]+)/gi , '').toLowerCase(); | |
var temp=""; | |
for (var i = cleanUp.length - 1; i >= 0; i--) { | |
temp += cleanUp[i]; | |
} | |
if(temp == og){ | |
return true; | |
} | |
return false; | |
} | |
palindrome("eye"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment