Last active
November 29, 2015 14:29
-
-
Save AllThingsSmitty/928c08a1669a06e727f0 to your computer and use it in GitHub Desktop.
Determine if a given string is a palindrome
This file contains hidden or 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
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