Skip to content

Instantly share code, notes, and snippets.

View supercamilo's full-sized avatar

Juan Jimenez supercamilo

  • Mobile Reach
  • Medellin, Colombia
View GitHub Profile
// flattens an array of arbitrarily nested arrays of integers into a flat array of integers
const flatten = (values) => values.reduce(
// concat single values and recursively flatten any nested arrays
(acc, val) => acc.concat(Array.isArray(val) ? flatten(val) : val), []
);
export default flatten;