After checking out this post on flattening arrays, I noticed that no one had used the array method forEach
. I gave it a try and failed, only receiving back an empty array:
let arrays = [[1, 2, 3], [4, 5], [6]];
let result = [];
arrays.forEach( (element) => {
result.concat(element)
})
console.log(result) //[]
Where did I go wrong?