Created
December 27, 2019 02:21
-
-
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.
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) { | |
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