Last active
November 26, 2015 04:22
-
-
Save terakilobyte/025b44fd3a5931d3680b 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
function steamroller(arr) { | |
// I'm a steamroller, baby | |
function flatReduce(collection) { | |
return collection.reduce((acc, curr) => { | |
return acc.concat(Array.isArray(curr) ? flatReduce(curr) : curr); | |
}, []); | |
} | |
return flatReduce(arr); | |
} | |
steamroller([1, [2], [3, [[4]]]]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment