Created
August 13, 2011 15:35
-
-
Save joseanpg/1143962 to your computer and use it in GitHub Desktop.
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
| var phineas = (function(){ | |
| function aplaneitor(soa,acu) { | |
| if (soa instanceof Array) { | |
| for (var j=0, len = soa.length;j<len;j++) { | |
| aplaneitor(soa[j],acu); | |
| } | |
| } | |
| else { | |
| acu.push(soa); | |
| } | |
| } | |
| return function(a,sep) { | |
| var acu = []; | |
| aplaneitor(a,acu); | |
| return acu.join(sep); | |
| } | |
| })(); | |
| console.log(phineas(['a',['b',['c',['d']]]],'*')); | |
| console.log(phineas(["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