Created
August 8, 2018 16:40
-
-
Save ariesabao/24593847e1de283febcac99ce172968a to your computer and use it in GitHub Desktop.
JavaScript Algorithms and Data Structures Projects
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) { | |
str = str.toLowerCase().replace(/[\W_]/g, ''); | |
for(var i = 0, len = str.length - 1; i < len/2; i++) { | |
if(str[i] !== str[len-i]) { | |
return false; | |
} | |
} | |
return true; | |
} | |
palindrome("eye"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment