Skip to content

Instantly share code, notes, and snippets.

@johnstew
Created February 14, 2013 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnstew/4955527 to your computer and use it in GitHub Desktop.
Save johnstew/4955527 to your computer and use it in GitHub Desktop.
5 minute palindrome tester. breaks for spaces.
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