Skip to content

Instantly share code, notes, and snippets.

@chris-kobrzak
Created October 21, 2015 22:54
Show Gist options
  • Save chris-kobrzak/bb8f195abbbefca6a142 to your computer and use it in GitHub Desktop.
Save chris-kobrzak/bb8f195abbbefca6a142 to your computer and use it in GitHub Desktop.
Sample implementation of palindrome checking function in JavaScript
function isPalindrome( string ) {
var notWordPattern = /\W/g,
alphaNumericOnly = string
.replace( notWordPattern, "" )
.toLowerCase(),
alphaNumericOnlyReversed = alphaNumericOnly.reverse()
return alphaNumericOnly == alphaNumericOnlyReversed
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment