Flatten the array solution(Two sollutions)
Code

# Code
```javascript []
/**
 * @param {Array} arr
 * @param {number} depth
 * @return {Array}
 */
var flat = function (arr, n) {
    const result = arr.reduce((acc, curr, index)=>{
           if(Array.isArray(curr) && n>0){
               acc.push(...flat(curr, n-1));
           } else {
            acc.push(curr)
           }
           return acc;
    }, []);

    return result;
};
```
['JavaScript']