✅ JavaScript - recursive solution
Approach\n Describe your approach to solving the problem. \nFlatten arrays recursively until n equals 0, then return array itself.\n\n# Code\n\n/**\n * @param {
# Approach\n<!-- Describe your approach to solving the problem. -->\nFlatten arrays recursively until n equals 0, then return array itself.\n\n# Code\n```\n/**\n * @param {any[]} arr\n * @param {number} depth\n * @return {any[]}\n */\nvar flat = function (arr, n) {\n    if (n === 0) return arr;\n\n    let result = [];\n\n    for (let num of arr) {\n        if (Array.isArray(num)) {\n            result.push(...flat(num, n - 1));\n        } else {\n            result.push(num);\n        }\n    }\n\n    return result;\n};\n```
['JavaScript']