Skip to content

Instantly share code, notes, and snippets.

@matthieu-foucault
Last active January 3, 2019 06:37
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 matthieu-foucault/2de97857d642fa45d408a0fb09640e10 to your computer and use it in GitHub Desktop.
Save matthieu-foucault/2de97857d642fa45d408a0fb09640e10 to your computer and use it in GitHub Desktop.
Flatten function
const flatten = (array) => {
const result = [];
for (e of array) {
if (Array.isArray(e)) {
for (ee of flatten(e)) {
result.push(ee);
}
} else {
result.push(e);
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment