Skip to content

Instantly share code, notes, and snippets.

@maxmatthews
Created May 18, 2022 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxmatthews/6feaaba213b00812fb9aa3321a1030e4 to your computer and use it in GitHub Desktop.
Save maxmatthews/6feaaba213b00812fb9aa3321a1030e4 to your computer and use it in GitHub Desktop.
Palindrome
function palindrome(str) {
str = str
.replace(/[\s\.\,_-]/g, "")
.toLowerCase()
.replace("/", "")
.replace(":", "")
.replace("(", "")
.replace(")", "");
console.log(str, str.split("").reverse().join(""));
if (str === str.split("").reverse().join("")) {
return true;
}
return false;
}
palindrome("eye");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment