Skip to content

Instantly share code, notes, and snippets.

@Risyandi
Created January 17, 2023 04:01
Show Gist options
  • Save Risyandi/75a1ac3f9d5abb5490fb5b425ac2847f to your computer and use it in GitHub Desktop.
Save Risyandi/75a1ac3f9d5abb5490fb5b425ac2847f to your computer and use it in GitHub Desktop.
check have a palindrome
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