Skip to content

Instantly share code, notes, and snippets.

@ryandotsmith
Created November 23, 2010 05:50
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 ryandotsmith/711331 to your computer and use it in GitHub Desktop.
Save ryandotsmith/711331 to your computer and use it in GitHub Desktop.
simple palindrome function in JS
var palindrome = function(center){
var first = center.slice(0,1);
var last = center.slice(-1);
var mid = center.slice(1,-1);
if(mid == "") { print("true"); return;}
if(first == last) { palindrome(mid); }
else { print("false"); }
}
palindrome("abba");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment