Skip to content

Instantly share code, notes, and snippets.

@Maslor
Created March 21, 2016 16:59
Show Gist options
  • Save Maslor/151013968da9952434f5 to your computer and use it in GitHub Desktop.
Save Maslor/151013968da9952434f5 to your computer and use it in GitHub Desktop.
palindrome javascript
function palindrome(str) {
var array = [];
var correctedString = str.replace(/[^\w]|_/g, "").toLowerCase();
array = correctedString.split("");
var string = array.join("");
var reversedString = array.reverse().join("");
if (string == reversedString) return true;
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment