-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
We can flatten multi dimensional array using recursion in this way.
const flatten_array = arr => {
// Concat given array with an empty array
let flatten = [].concat(...arr);
// Check if the flatten array contains any further array
// If so do recursion of that array else return the array
return flatten.some(Array.isArray) ? flatten_array(flatten) : flatten;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels