Skip to content

Instantly share code, notes, and snippets.

@polinabee
Last active March 10, 2022 10:13
Show Gist options
  • Save polinabee/b1d2e633bc666c29c42afb8bda7e4478 to your computer and use it in GitHub Desktop.
Save polinabee/b1d2e633bc666c29c42afb8bda7e4478 to your computer and use it in GitHub Desktop.
Have the function PalindromeTwo(str) take the str parameter being passed and return the string true if the parameter is a palindrome, (the string is the same forward as it is backward) otherwise return the string false. The parameter entered may have punctuation and symbols but they should not affect whether the string is in fact a palindrome. F…
function PalindromeTwo(str) {
if (str.toLowerCase().replace(/[^a-z]/g, '') == str.toLowerCase().replace(/[^a-z]/g, '').split('').reverse().join('')){
return true;
}
return false;
}
PalindromeTwo(readline());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment