🔥🔥 Detailed Solution Using Recursion In Javascript  || Faster Than 80%✔✔
Intuition\n Describe your first thoughts on how to solve this problem. \n According to the Problem Statement:\n 1. If depth of the current array is less than n 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n According to the Problem Statement:\n 1. If depth of the current array is less than n then we will flatten it.\n 2. If depth of the current array is equal to n then we will flatten it.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n 1. We will use Recursive Function Flat(arr,depth,n).\n 2. if depth==n then we will simply return array //Base Condition.\n 3. else we will try to flatten array by traversing the array completely.\n    ```\n    let i=0;\n    let Arr=[];\n    while(i<arr.length)\n    {\n          //If current element is integer then no need to flatten it\n          if(Number.isInteger(arr[i]))\n          {\n             Arr.push(arr[i]);\n          }\n          else\n          {\n             //we will call Flat(arr[i],depth+1,n) to flatten this arr\n              let tempArr=Flat(arr[i],dept1,n);\n              tempArr.forEach((ele)=>{\n                  Arr.push(ele);\n              })\n          }\n          i+=1;\n    }\n    return Arr;\n```\n\n# Complexity\n- Time complexity: O(n*N)\n- where N max number of ele in particular depth while flatting given array.\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(Total number of integer in array)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n```\n/**\n * @param {any[]} arr\n * @param {number} depth\n * @return {any[]}\n */\nvar Flat=function(arr,depth,n){\n         if(depth==n)\n         {\n            return arr;\n         }\n         let Arr=[];\n         let i=0;\n         while(i<arr.length)\n         {\n               if(Number.isInteger(arr[i]))\n               { \n                  Arr.push(arr[i]);\n               }\n               else\n               {\n                  const v=Flat(arr[i],depth+1,n);  \n                  v.forEach((x)=>{\n                      Arr.push(x);\n                  });\n               }\n               i+=1;  \n         }\n         return Arr;\n}\nvar flat = function (arr, n) {\n           return Flat(arr,0,n);\n};\n```\n```
['JavaScript']