Created
February 20, 2017 14:39
-
-
Save erubi/cf9926b7f476674b7724cb255fae029f to your computer and use it in GitHub Desktop.
Answer to flatten question for Citrusbyte
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
| const flatten = (arr) => { | |
| return arr.reduce((flat, toFlatten) => { | |
| if (Array.isArray(toFlatten)) return flat.concat(flatten(toFlatten)); | |
| return flat.concat(toFlatten); | |
| }, []); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment