Skip to content

Instantly share code, notes, and snippets.

@jneira
Forked from joseanpg/phineas.js
Created August 13, 2011 21:39
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 jneira/1144274 to your computer and use it in GitHub Desktop.
Save jneira/1144274 to your computer and use it in GitHub Desktop.
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