Skip to content

Instantly share code, notes, and snippets.

@eamodeorubio
Created August 17, 2011 17:28
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 eamodeorubio/1152082 to your computer and use it in GitHub Desktop.
Save eamodeorubio/1152082 to your computer and use it in GitHub Desktop.
Advanced Concatenator (GEJS)
// This fails with ["a,,", "b"] Do you know how to fix it? We'll see how to in class
var concatenator = function(arr, optSeparator) {
if(!arr || typeof(arr.join) != 'function')
return;
var separator = typeof(optSeparator) == 'string' ? optSeparator : ',';
var r = arr.join();
if(separator != ',')
r = r.replace(/,/g, separator);
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment