Skip to content

Instantly share code, notes, and snippets.

@levivoelz
Created February 17, 2017 20:56
Show Gist options
  • Save levivoelz/c2044dbac2865554b01766154d37c616 to your computer and use it in GitHub Desktop.
Save levivoelz/c2044dbac2865554b01766154d37c616 to your computer and use it in GitHub Desktop.
const flatten = (array) => {
if (array.length === 0) { return array }
return array.reduce((a, b) => {
return a.concat(Array.isArray(b) ? flatten(b) : b)
}, [])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment