Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mi solución al primer ejercico para el tercer día de gejs
concatena = function (obj, sep) {
var separator = "";
desarraygar = function (obj) {
var result = "";
if (({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase() == "string") {
result += separator + obj;
separator = sep || ",";
}
else {
for (var i=0; i<obj.length; i++) {
result += desarraygar (obj[i]);
}
}
return(result);
}
return desarraygar (obj);
}
console.log(concatena(["hola", ["soy", ["juan", "fernandez"] ], "y", ["no", "tengo", ["dinero"] ] ]));
console.log(concatena(["hola", ["soy", ["juan", "fernandez"] ], "y", ["no", "tengo", ["dinero"] ] ], ";"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.