Created
December 3, 2015 04:55
-
-
Save anonymous/1644b12ac4daab48a1f8 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/mattnwa '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: @mattnwa | |
// 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 replaceAndLower =str.replace(/[^A-Z0-9]/ig, "").toLowerCase(); | |
var reversedStr = replaceAndLower.split('').reverse().join(''); | |
if (reversedStr === replaceAndLower) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
palindrome("eye"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment