Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
Intermediate · 20 XP

Flatten Deeply Nested Arrays

Write a function `flattenArray(arr)` that takes an array containing arbitrarily nested arrays and returns a single, completely flat 1-dimensional array. ### Requirements: - Do not use built-in `Array.prototype.flat(Infinity)`. - Handle empty arrays, single numbers, and arrays nested 5+ levels deep. - Preserve the original ordering of elements.

Show Step-by-Step Hint
  • • You can use recursion by checking `Array.isArray(item)` for each element.
  • • Alternatively, you can use a stack or `Array.prototype.reduce`.
Type: Code Challenge
Runtime: JAVASCRIPT
JAVASCRIPT solutionCHALLENGE #1
Solutions and scores are stored in your private attempt history.Sign in to submit challenge