Created
January 12, 2018 20:31
-
-
Save ealipio/7fb5bb025b8dd9c12923d6b2d8e36db1 to your computer and use it in GitHub Desktop.
flatten an array
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
flattens = (arr) => arr.reduce( (flat, toFlatten) => flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten) , []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment