Ad
Algorithms
Logic

Just a tiny bit shorter, than original.

Code
Diff
  • const flatten = arr =>
      arr.reduce((acc, item) =>  acc.concat(Array.isArray(item) ? flatten(item) : [item]), []);
    • const flatten = arr =>
    • arr.reduce((acc, item) => Array.isArray(item) ? [...acc, ...flatten(item)] : [...acc, item], []);
    • arr.reduce((acc, item) => acc.concat(Array.isArray(item) ? flatten(item) : [item]), []);