You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;
}
The text was updated successfully, but these errors were encountered:
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;
}
The text was updated successfully, but these errors were encountered: