Back to Problem Library
Arrays

Flatten Array (Deep)

easyJS / TS

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]
Includes TypeScript & JavaScript starter code
Start Interview with this Problem