Skip to content

Instantly share code, notes, and snippets.

View hwangar's full-sized avatar

Juan Arias hwangar

  • Appfire
  • Pamplona, Spain
View GitHub Profile
@hwangar
hwangar / flatten.js
Created August 9, 2017 18:09
Flatten array
const a = [[1,2,[3]],4];
const flatten = list => list.reduce(
(all, elem) => all.concat(Array.isArray(elem) ? flatten(elem) : elem), []
);
console.log('------>', flatten(a));