Created
December 28, 2015 17:56
-
-
Save Lewiscowles1986/69a93503a190f02af9fa to your computer and use it in GitHub Desktop.
Weird Palindrome
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
/* | |
* so I decided to check out freecodecamp today, just to see how it was | |
* | |
* It's okay, but I have to question the value of learning to write a palindrome checker, that to my mind is not much use... | |
* Here was my punt at it (it passed, I just don't love the look of it) | |
*/ | |
function palindrome(str) { | |
// Good luck! | |
str = str.toLowerCase().replace(/[^a-z0-9]/g, ''); | |
var reversed = str.split("") | |
.reverse() | |
.join(""); | |
console.log(reversed,str) | |
return str.toLowerCase() === reversed; | |
} | |
palindrome("A man, a plan, a canal. Panama"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment