Skip to content

Instantly share code, notes, and snippets.

@Uzwername
Created March 21, 2021 02:23
Show Gist options
  • Save Uzwername/15d5d8e59b0fd3bdbcb62dd04226061e to your computer and use it in GitHub Desktop.
Save Uzwername/15d5d8e59b0fd3bdbcb62dd04226061e to your computer and use it in GitHub Desktop.
const flatToBase = array => array.reduce(
(accumulator, value) => accumulator.concat(
Array.isArray(value) ? flatToBase(value) : value
),
[],
);
flatToBase([[[[[[[ 42 ]]]], 36]]]); // -> [ 42, 36 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment