Simple Recursive Approach (JS)
ApproachRecursive ApproachComplexity
Time complexity: O(N∗n)

Space complexity:O(N+n)
Code
# Approach
<!-- Describe your approach to solving the problem. -->
Recursive Approach
# Complexity
- Time complexity: $$O(N*n)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:$$O(N+n)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```javascript []
/**
 * @param {Array} arr
 * @param {number} depth
 * @return {Array}
 */
var flat = function (arr, n) {
    if (!n) return arr
    const newArr = []
    arr.forEach(el => {
        if (Array.isArray(el)) { newArr.push(...flat(el, n - 1)) }
        else { newArr.push(el) }
    })
    return newArr
};
```
['Recursion', 'JavaScript']