Skip to content

Instantly share code, notes, and snippets.

@JaymesKat
Created December 27, 2019 02:21
Show Gist options
  • Save JaymesKat/6828d88be4b75fab5e2bf8e0a30c8674 to your computer and use it in GitHub Desktop.
Save JaymesKat/6828d88be4b75fab5e2bf8e0a30c8674 to your computer and use it in GitHub Desktop.
A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.
function palindrome(str) {
let text = str.toLowerCase().replace(/[^a-z0-9]/g, "");
const revText = text.split("").reverse().join("");
return text === revText;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment