Array.prototype.flatintermediateconst arr = [1, [2, [3, [4]]]]
arr.flat(2) // β [1, 2, 3, [4]]Pass a depth number to flat() to control how many nesting levels are flattened.
You can specify a numeric depth to control how many levels are unwrapped. flat(2) flattens two levels.
Challenge: Implement flatTwo(arr) that flattens exactly two levels using arr.flat(2).
flatTwo([1, [2, [3, [4]]]]) // β [1, 2, 3, [4]]
flatTwo([[1], [[2, 3]]]) // β [1, 2, 3]