Array flat
Here are two functions
flatArray
andflatArrayRecursive
that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4].
They both receive one argument, the array. Return value is a new (flattened) array.
Run tests with npm test
, obviously you need to do npm install
before that.