Created
January 16, 2017 19:39
-
-
Save GheorgheoiuNicolae/141e32bc303b60464af461ccb9370c26 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
function flatten(arr) { | |
var res = []; | |
for(var i = 0; i < arr.length; i++) { | |
if(Array.isArray(arr[i])) { | |
res = res.concat(flatten(arr[i])); | |
} else { | |
res.push(arr[i]); | |
} | |
} | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment