Flatten the Array
You are required to implement a custom Array.prototype.flat function.
This function creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.
// Input
const arr1 = [0, 1, 2, [3, 4]];
// Output
const res = flat(arr, 1);
console.log(res); // [0, 1, 2, 3, 4]