Created
May 29, 2018 16:48
-
-
Save boton/dd244b67ccca35c46d85c0da6b2d4c23 to your computer and use it in GitHub Desktop.
Array flatten
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
| // borrowed from https://gist.github.com/Integralist/749153aa53fea7168e7e#gistcomment-1457123 | |
| const flatten = list => list.reduce( | |
| (accumulator, element) => accumulator.concat(Array.isArray(element) | |
| ? flatten(element) | |
| : element), | |
| [] | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment