Created
June 30, 2022 14:57
-
-
Save juareznjunior/2f89a92520a4ffea58c44be2f4b1e906 to your computer and use it in GitHub Desktop.
palindrome
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(/[^a-z0-9]/ig,''); | |
let strEqual = str.split('').reverse().join(''); | |
console.log(str, strEqual) | |
return strEqual === str | |
} | |
console.log( | |
palindrome("_eye") | |
,palindrome("never odd or even") | |
,palindrome("nope") | |
,palindrome("1 eye for of 1 eye.") | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment