So there is a challenge about the Splice function that I dont really get, Ironically I understand the .splice part but not the .reduce() part of this code, mdn wasn’t really helpful either…
function sumOfTen(arr) {
const a = arr.splice(2,2)
return arr.reduce((a, b) => a + b);
}
console.log(sumOfTen([2, 5, 1, 5, 2, 1]));
From what I’ve read it applys the function a+b to every element of arr. since I defined a as arr.splice(2,2) it should be 1 and 5 so 6… how do I get to 10 in the end result and what do I need b for?