I have the following code below:
const intersection = (arr) => {
//console.log(arr)
return arr.reduce((a,e) => a+e, [])
}
const arr1 = [5, 10, 15, 20];
const arr2 = [15, 88, 1, 5, 7];
const arr3 = [1, 10, 15, 5, 20];
console.log(intersection([arr1, arr2, arr3]));
I am expecting my code to print [5,10,15,2015,88,1,5,71,10,15,5,20] but instead it's printing 5,10,15,2015,88,1,5,71,10,15,5,20
What am I doing wrong?
+operator to arrays, which javascript doesn't support. Useconcatinstead:(a,e) => a.concat(e)