Skip to content

Instantly share code, notes, and snippets.

@arecvlohe
Created June 23, 2017 01:31
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 arecvlohe/c8f9558867a9859df5d972d7f26bc40c to your computer and use it in GitHub Desktop.
Save arecvlohe/c8f9558867a9859df5d972d7f26bc40c to your computer and use it in GitHub Desktop.
function flatten(array) {
return array.reduce((acc, curr) => {
if (Array.isArray(curr)) {
return flatten([...acc, ...curr])
}
return acc.concat(curr)
}, [])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment