Created
March 21, 2016 16:59
-
-
Save Maslor/151013968da9952434f5 to your computer and use it in GitHub Desktop.
palindrome javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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