Created
February 14, 2013 19:24
-
-
Save johnstew/4955527 to your computer and use it in GitHub Desktop.
5 minute palindrome tester. breaks for spaces.
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 temp = str.split(""); | |
var temp2 = []; | |
for (i = temp.length - 1; i >= 0; i--) { | |
temp2.push(temp[i]); | |
} | |
var strtemp = temp2.join(""); | |
var strtemp2 = temp.join(""); | |
return (strtemp === strtemp2) ? true : false; | |
} | |
document.write(Palindrome("racecar")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment