Easiest Solution Ever
Code\n\nvar flat = function (arr, n) {\n    // if n = 0 then we return arr or if all the element of array is \n    // integer (not an array) we return arr.\n   
# Code\n```\nvar flat = function (arr, n) {\n    // if n = 0 then we return arr or if all the element of array is \n    // integer (not an array) we return arr.\n    if(n == 0 || arr.every((item) => !Array.isArray(item))) return arr;\n    const result = [];\n    for(let i=0;i<arr.length;i++)\n      if(Array.isArray(arr[i]))\n        result.push(...arr[i]);\n      else\n        result.push(arr[i]);\n    return flat(result,n-1);\n};\n```
['JavaScript']