Last active
March 3, 2017 13:16
-
-
Save tobiaslins/46c512f5bd65631fe38e6091cbbd8099 to your computer and use it in GitHub Desktop.
Revisions
-
tobiaslins revised this gist
Mar 3, 2017 . 1 changed file with 2 additions and 2 deletions.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 @@ -1,8 +1,8 @@ const testArray = [[1,2,[3]],4] const flatArray = (arr) => arr.reduce((a, b) => { const newValue = Array.isArray(b) ? flat(b) : b return a.concat(newValue) }, []) console.log(flatArray(testArray)) -
tobiaslins revised this gist
Mar 3, 2017 . 1 changed file with 4 additions and 6 deletions.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 @@ -1,10 +1,8 @@ const testArray = [[1,2,[3]],4] const flat = (arr) => arr.reduce((a, b) => { const newValue = Array.isArray(b) ? flat(b) : b return a.concat(newValue) }, []) console.log(flat(testArray)) -
tobiaslins renamed this gist
Mar 3, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
tobiaslins created this gist
Mar 3, 2017 .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,10 @@ const testArray = [[1,2,[3]],4] const flat = (arr) => { return arr.reduce((a, b) => { const newValue = Array.isArray(b) ? flat(b) : b return a.concat(newValue) }, []) } console.log(flat(testArray))