Explorer
Node.js

Write a function `flattenArray(arr)` that flattens a nested array one level deep.

Problem Statement

Write a function `flattenArray(arr)` that flattens a nested array one level deep.

Complexity

Time Complexity: -

Space Complexity: -

Hints

šŸ’” Hint 1: Array.flat() flattens nested arrays. šŸ’” Hint 2: By default, .flat() flattens one level. Pass Infinity for full flatten. šŸ’” Hint 3: return arr.flat(); āœ… Solution: ```javascript function flattenArray(arr) { return arr.flat(); } ```

Flat Array

Easy
Write a function `flattenArray(arr)` that flattens a nested array one level deep.
Editor
Loading Editor...
Evaluate code
Output:Click "Run" above to execute and verify your code here.
[1,2,3,4,[5]]