Created
February 26, 2019 13:53
-
-
Save piotrjaw/2a1b7e12c6cdd31f07062d5fdcf3359b to your computer and use it in GitHub Desktop.
Revisions
-
piotrjaw created this gist
Feb 26, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ 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;