Skip to content

Instantly share code, notes, and snippets.

@Lewiscowles1986
Created December 28, 2015 17:56
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 Lewiscowles1986/69a93503a190f02af9fa to your computer and use it in GitHub Desktop.
Save Lewiscowles1986/69a93503a190f02af9fa to your computer and use it in GitHub Desktop.
Weird Palindrome
/*
* 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