Created
August 17, 2011 17:28
-
-
Save eamodeorubio/1152082 to your computer and use it in GitHub Desktop.
Advanced Concatenator (GEJS)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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