/flatten-array-tail-recursion

Recursively flatten an array using tail recursion

Primary LanguageJavaScript

Flattening an array

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

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

Implementation

See utils/array.flatten for the documented code.

Testing

See test.js for the test cases.

Running

Main:

node index.js

Tests:

node test.js