Skip to content

Instantly share code, notes, and snippets.

@juareznjunior
Created June 30, 2022 14:57
Show Gist options
  • Save juareznjunior/2f89a92520a4ffea58c44be2f4b1e906 to your computer and use it in GitHub Desktop.
Save juareznjunior/2f89a92520a4ffea58c44be2f4b1e906 to your computer and use it in GitHub Desktop.
palindrome
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