Simple 1 line solution
Approach\nRecursively reduce arr by recursing through non-numerical inputs until base case of n === 0. If e is an element, it\'s pushed into acc, otherwise, res
# Approach\nRecursively reduce `arr` by recursing through non-numerical inputs until base case of `n === 0`. If `e` is an element, it\'s pushed into `acc`, otherwise, result of recursive call is unpacked before being pushed. For each case we return `acc` in the `reduce` HOF.\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```\nvar flat = function (arr, n) {\n    return n === 0 ? arr : arr.reduce(\n            (acc, e) => typeof(e) === "number" ? \n              (acc.push(e), acc) : (acc.push(...flat(e, n-1)), acc),\n           []);\n};\n```
['Recursion', 'JavaScript']