Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Combine Arrays with Spread

Data Structures, Operators & Stringseasy

Course · Section 9: Data Structures, Modern Operators and Strings · Lecture 111: The Spread Operator (...)

Implement `combine(a, b)` returning a new array with all of `a` then all of `b`, using spread.

Sample tests

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

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • concat works too, but push mutates.
Visualize this concept: Spread and Rest →
Approach & explanation (try first)

Spreading both arrays builds a new combined array without mutation.

Loading...
⌘/Ctrl + Enter

Run your code to see results.