Created
December 20, 2016 00:41
-
-
Save bflannery/a060975a51225fd385932e5dade77849 to your computer and use it in GitHub Desktop.
Palindrome Checker
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
// Return true if the given string is a palindrome. Otherwise, return false. | |
function palindrome(str) { | |
var x = str.replace(/[^a-z0-9+]+/gi, '').toLowerCase(); | |
if(x.split('').reverse().join('') === x) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
console.log(palindrome("eye")); | |
console.log(palindrome("2A3*3a2")); | |
console.log(palindrome("1 eye for of 1 eye.")); | |
console.log(palindrome("My age is 0, 0 si ega ym.")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment