Created
June 15, 2016 12:55
-
-
Save dmitry-vsl/60065ffe3ed775845230542f2e553e8c 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 result = []; | |
function doFlatten(arr){ | |
if(Array.isArray(arr)){ | |
arr.forEach(doFlatten); | |
}else{ | |
result.push(arr); | |
} | |
} | |
doFlatten(arr); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment