Created
August 16, 2011 09:02
-
-
Save Osukaru/1148697 to your computer and use it in GitHub Desktop.
Mi solución al primer ejercico para el tercer día de 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
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