-
-
Save joseanpg/1144144 to your computer and use it in GitHub Desktop.
Concatenar arrays anidados recursivamente
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
function aplaneitor2(arr,sep){ | |
return function step(a){return Array.isArray(a) ? a.map(step).join(sep) : a}(arr); | |
} | |
var test = ["hola", ["soy", ["juan", "fernandez"] ], "y", ["no", "tengo", ["dinero"] ] ]; | |
console.log(aplaneitor2(test,'**')) // -> 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