Flatten any-depth nested array WITHOUT using .flat(Infinity).
Write a recursive function flatten(arr) that flattens arrays of any depth. Forbidden: arr.flat(Infinity).
Use .reduce + Array.isArray + recursion.
flatten([1, [2, [3, [4]], 5]]) → [1, 2, 3, 4, 5]
Sign in to save your code and track progress across devices.