Skip to content

Instantly share code, notes, and snippets.

@Lee182
Created November 17, 2015 20:54
Show Gist options
  • Save Lee182/a64ff2eb3d142421b518 to your computer and use it in GitHub Desktop.
Save Lee182/a64ff2eb3d142421b518 to your computer and use it in GitHub Desktop.
Want to flatten that array, here's a recurrsive way to do that
function flatten(arr) {
var ans = []
arr.forEach(function(ar){
if ( Array.isArray(ar) ) { ans = ans.concat( flatten(ar) ) }
else { ans.push(ar) }
})
return ans
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment