-
-
Save jneira/1144274 to your computer and use it in GitHub Desktop.
This file contains 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
function flatten (xs) { | |
return xs.reduce (function (acc,x){ | |
return acc.concat(Array.isArray(x)?flatten(x):x)},[]) | |
} | |
function phineas (arr,sep) { | |
return flatten(arr).join(sep) | |
} | |
var res=phineas(["hola", ["soy", ["juan", "fernandez"] ], "y", ["no", "tengo", ["dinero"] ] ],"*") | |
console.log(res) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment