Skip to content

Instantly share code, notes, and snippets.

@ryansmith3136
Created November 23, 2010 05:50
Show Gist options
  • Select an option

  • Save ryansmith3136/711331 to your computer and use it in GitHub Desktop.

Select an option

Save ryansmith3136/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