Skip to content

Instantly share code, notes, and snippets.

@ryandotsmith
Created November 23, 2010 05:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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