Created
January 6, 2019 22:18
-
-
Save akinolu52/f423f3af15ed7f7e5cc2e74c671e05d7 to your computer and use it in GitHub Desktop.
to flatten an array in Javascript
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
function flattenArray(arr) { | |
return arr.reduce((acc, e) => Array.isArray(e) ? acc.concat(flattenDeep(e)) : acc.concat(e), []); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment