Skip to content

Instantly share code, notes, and snippets.

@bmansk8
Created April 2, 2019 16:11
Show Gist options
  • Save bmansk8/d792805b1181581d6f64b7a5ee9c75f9 to your computer and use it in GitHub Desktop.
Save bmansk8/d792805b1181581d6f64b7a5ee9c75f9 to your computer and use it in GitHub Desktop.
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