Created
January 16, 2024 18:33
-
-
Save berdfandrade/acb9fe2bdb1f7492c659c562ae393822 to your computer and use it in GitHub Desktop.
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 palindrome(str) { | |
str = str.toLowerCase(); | |
var regex = /[^A-Za-z0-9]/g; | |
var palavraLimpa = str.replace(regex, ""); | |
let palavraInvertida = palavraLimpa.split("").reverse().join("") | |
if(palavraLimpa === palavraInvertida){ | |
return true | |
} else { | |
return false | |
} | |
} | |
palindrome("race car"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment