Created
February 26, 2019 13:53
-
-
Save piotrjaw/2a1b7e12c6cdd31f07062d5fdcf3359b 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
| const flatten = (arr) => { | |
| const result = []; | |
| const _flatten = (arrayOrValue) => { | |
| if (Array.isArray(arrayOrValue)) { | |
| arrayOrValue.map(_flatten); | |
| } else { | |
| result.push(arrayOrValue); | |
| } | |
| }; | |
| arr.map(_flatten); | |
| return result; | |
| }; | |
| export default flatten; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment