Skip to main content
🧩 Algorithms & Problem Solving

Flatten an Array

Turn [[1, 2], [3], [4, 5]] into [1, 2, 3, 4, 5]. reduce + concat merges each sub-array into an accumulator.

Your task

Write flatten(arr) that flattens an array of arrays by one level.

⚑ 35 XP
solution.jsRuns in your browser
Loading editor…
Tests3 to pass
basic
with empties
empty

Run your code to check these.