Created
January 17, 2023 04:01
-
-
Save Risyandi/75a1ac3f9d5abb5490fb5b425ac2847f to your computer and use it in GitHub Desktop.
check have a 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
let string = "A man, a plan, a canal: Panama"; | |
function palindromeTwo(alphabet) { | |
alphabet = alphabet.replace(/[^a-z0-9]/gi, "").toLowerCase(); | |
let reverse = alphabet.split("").reverse().join(""); | |
return alphabet === reverse; | |
} | |
palindromeTwo(string); | |
// the output will be result : true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment