-
-
Save jouderianjr/758ffea323020512e01b865b75062485 to your computer and use it in GitHub Desktop.
poitinha
This file contains hidden or 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 removeSpecialChars(str) { | |
return str.replace(/ /gi,"").replace(/[_\W]/gi,"").toLowerCase(); | |
} | |
function reverseString(str) { | |
return str.split('').reverse().join(''); | |
} | |
function palindrome(str) { | |
var cleanedString = removeSpecialChars(str); | |
var reverseCleanedString = reverseString(cleanedString); | |
return cleanedString === reverseCleanedString; | |
} | |
palindrome("_eye"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment