JavaScript || Easy to Understand ✅✅
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {any[]} arr\n * @param {number} depth\n * @return {any[]}\n */\nvar flat = function (arr, n) {\n    \n    if(n==0){\n        return arr.slice();\n    }\n    \n    let newArr = [];\n\n    arr.forEach((val) => {\n        if(Array.isArray(val)){\n            const nested = flat(val, n-1);\n            newArr.push(...nested);\n        }\n        else{\n            newArr.push(val);\n        }\n    });\n\n    return newArr;\n};\n```
['JavaScript']