Elastic N.V.·Software Engineer·Technical Phone Screen
- You're given a JavaScript flatten(arr) function that recursively flattens nested arrays. Find and fix all the bugs in it.
- Walk through test cases for the fixed flatten function: empty arrays, deeply nested input, and mixed types.
“The bugs they were fishing for: not recursing into non-array elements, misusing concat so it mutates or doesn't spread correctly, and circular reference handling causing infinite recursion.”