Skip to content

Instantly share code, notes, and snippets.

@kurai021
Created October 2, 2018 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurai021/df844644efbfdae76514a062808a978b to your computer and use it in GitHub Desktop.
Save kurai021/df844644efbfdae76514a062808a978b to your computer and use it in GitHub Desktop.
Flat a nested array
function flatten(array) {
var flat_array = [];
array.forEach(function(e){
flat_array = flat_array.concat(e)
})
console.log("Flat array: " + flat_array)
}
flatten([2,4,9,[5,6,[8,10],4],7])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment