I'm getting a little confused with using reduce.
it's array.reduce((accumulator, value) => do something with accumulator, why is this returning back an empty array?
let a = [
[1,2],
[
[3,4]
],
[
[[5],[6]]
]
];
const flatten = arr => arr.reduce((a, v) => {
v instanceof Array ? flatten(v) : a.push(v);
return a;
}, [])
console.log(flatten(a));
Array.prototype.flat()orArray.prototype.flatMap()is not being used?