Arrays

Flatten Array (Deep)

easyJS SpecificJS / TS7 tests

Problem Statement

Write a function `flatten` that recursively flattens a nested array of arbitrary depth without using `Array.prototype.flat`.

Examples

Example:
flatten([1, [2, [3, [4]], 5]]) -> [1, 2, 3, 4, 5]
JavaScript & TypeScript starter code included
Run this as a live interview

Practice solo

7 test cases. No second person needed.

Get new interview exercises

Practice problems and review drills, sent when we publish new ones. No spam.

Unsubscribe anytime. We never share your address.