Skip to content

Instantly share code, notes, and snippets.

@brainyfarm
Created June 21, 2016 14:03
Show Gist options
  • Save brainyfarm/83f45606251f559e67f3b158f1a4253e to your computer and use it in GitHub Desktop.
Save brainyfarm/83f45606251f559e67f3b158f1a4253e to your computer and use it in GitHub Desktop.
Olawale/FreeCodeCamp: Check for Palindromes
function palindrome(str) {
// Rid the string of anything not letters or numbers
var cleaned = str.toLowerCase().replace(/[^a-z0-9]/g, "");
// Compare the cleaned string to iteself but in a reverse direction, return true or false
return (cleaned === cleaned.split("").reverse().join(""));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment