Skip to content

Instantly share code, notes, and snippets.

@MichaelWalker-git
Created March 4, 2017 03:10
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 MichaelWalker-git/f3ef4b53b4be4d28efd3d754d003896e to your computer and use it in GitHub Desktop.
Save MichaelWalker-git/f3ef4b53b4be4d28efd3d754d003896e to your computer and use it in GitHub Desktop.
oneArray
function oneArray(arr) {
return arr.reduce(function (first, next) {
return first.concat(Array.isArray(next) ? oneArray(next) : next);
}, []);
}
oneArray([[1,2,[3]],4]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment