/flatten

Write an algorithm to flatten an arbitrarily nested array of values.

Primary LanguageJavaScript

Part 1 – Flattening an array

Write an algorithm to flatten an arbitrarily nested array of values.

[ 1, [ 2, [ 3 ] ], 4 ] -> [ 1, 2, 3, 4 ]

If your language of choice includes a flattening function, please implement your own.

Versions

This kata was developed used node v17.3.0.

Tests

Jest framework was used in this repository to test the code. To run it, execute

    $ npm test

If you prefer watch mode, you can run

    $ npm run t-watch