Created
December 7, 2015 09:15
-
-
Save anonymous/38d6ddf4f47a85715de1 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/patrickcurl 's solution for Bonfire: Check for Palindromes
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
// Bonfire: Check for Palindromes | |
// Author: @patrickcurl | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-check-for-palindromes# | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function palindrome(str) { | |
// Good luck! | |
var myStr = str.replace(/[^A-Za-z0-9]/g, '').toLowerCase(); | |
reverseStr = myStr.split('').reverse().join(''); | |
if(myStr === reverseStr){ | |
return true; | |
} else { | |
return false | |
} | |
} | |
palindrome("eye"); | |
palindrome("palindrome"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment