Skip to content

Instantly share code, notes, and snippets.

@AllThingsSmitty
Last active November 29, 2015 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AllThingsSmitty/928c08a1669a06e727f0 to your computer and use it in GitHub Desktop.
Save AllThingsSmitty/928c08a1669a06e727f0 to your computer and use it in GitHub Desktop.
Determine if a given string is a palindrome
var input_str = 'madam';
function checkIfPalindrome(str) {
if (str == str.split('').reverse().join('')) {
alert('Yup, ' + str + 'is a palindrome');
} else {
alert('Nope, ' + str + ' isn\'t a palindrome');
}
}
checkIfPalindrome(input_str);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment