Ed

Working with nested data structures often requires flattening. Let's build a function that handles any depth!

Your Task:

  • Create a flatten(array, depth) function
  • It should flatten nested arrays up to depth levels
  • depth = 1 flattens one level, depth = Infinity flattens completely
  • Use recursion or the built-in Array.flat() for comparison
TypeScript Solution
Loading...

Submit your code to see test results