Skip to content

Instantly share code, notes, and snippets.

@joseanpg
Created August 13, 2011 13:24
Show Gist options
  • Select an option

  • Save joseanpg/1143847 to your computer and use it in GitHub Desktop.

Select an option

Save joseanpg/1143847 to your computer and use it in GitHub Desktop.
var concatenate = (function(){
var params;
//Auxiliares "privados"
function hasElements(){return params.length>0;}
function createString(){
var res = "";
for(var i=0;i<params.length;i++){
res += params[i];
if(isNotLastParam(i)){res+=",";}
}
return res;
}
function isNotLastParam(p1){
return (p1<params.length-1);
}
//La lambda protagonista
return function(parameters){
var result = "";
params = parameters || [ ];
if(hasElements()){result = createString();}
return result;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment