Created
May 23, 2016 04:22
-
-
Save egermano/5e39a4208051ec6d9286e17201369b8f 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
var flatten = function(a) { | |
return a.reduce(function (b, c) { | |
return b.concat(Array.isArray(c) ? flatten(c) : c); | |
}, []); | |
}; | |
var input = [[1,2,[3]],4]; | |
var output = flatten(input); | |
console.log(output); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment