Skip to content

Instantly share code, notes, and snippets.

@lachlan-eagling
Created March 16, 2017 21:16
Show Gist options
  • Select an option

  • Save lachlan-eagling/04d07f43081f3bb2344aa798d688098f to your computer and use it in GitHub Desktop.

Select an option

Save lachlan-eagling/04d07f43081f3bb2344aa798d688098f to your computer and use it in GitHub Desktop.
function palindrome(str) {
str = str.replace(/[^a-z\d]+/gi, '').toLowerCase();
var reversed = "";
for(var i = str.length - 1; i >= 0; i--){
reversed += str[i];
}
return str === reversed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment