FlattenDepth medium #array

by jiangshan @jiangshanmeta

Take the Challenge

Recursively flatten array up to depth times. For example: ```typescript type a = FlattenDepth<[1, 2, [3, 4], [[[5]]]], 2> // [1, 2, 3, 4, [5]]. flattern 2 times type b = FlattenDepth<[1, 2, [3, 4], [[[5]]]]> // [1, 2, 3, 4, [[5]]]. Depth defaults to be 1 ``` If the depth is provided, it's guaranteed to be positive integer.
Back Share your Solutions Check out Solutions

Related Challenges

459惻Flatten