← Back to challenges

Multidimensional Array into Single Dimensional Array

JavaScriptHardrecursionarrays

Instructions

Create a function that takes multidimensional array, converts into one dimensional array and returns it using recursion.

Examples

flatten([[17.2, 5, "code"]]) ➞ [17.2, 5, "code"]

flatten([[[[[2, 14, "rubber"]]], 2, 3, 4]])) ➞ [2, 14, "rubber", 2, 3, 4]

flatten([["balkot"]]) ➞ ["balkot"]

Notes

  • Input contains at least one element.
  • Use of built in methods is discouraged.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: New Word Builder