I have done it by reduce but I wanna do it by recursion and console prints error TypeError: arr[0].concat is not a function
let arrays = [[1, 2, 3], [4, 5], [6]];
// Your code here.
// → [1, 2, 3, 4, 5, 6]
let arr = arrays.reduce((acc, current, Index, arr) => {
return acc.concat(current);
}, []);
console.log(arr);
function flattening(arr) {
if (arr.length <= 1) return arr;
else return flattening(arr[0].concat(arr[1]));
}
console.log(flattening(arrays));