Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Concatenate Arrays via Spread

A Closer Look at Functionsmedium

Course · Section 10: A Closer Look at Functions · Lecture 135: Default Parameters

Implement `concatAll(...arrs)` returning a single array with the elements of every array argument, in order.

Sample tests

Input: concatAll([1], [2,3])
Output: [1,2,3]
Input: concatAll([])
Output: []

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Pushing arrays in produces nested arrays rather than a flat result.

Learning resources

  • MDN: Functions
Approach & explanation (try first)

Each argument is an array; spreading them into concat merges their elements in order.

Loading...
⌘/Ctrl + Enter

Run your code to see results.