I did this challenge a long time ago (I am a compSci student that was busy with other languages) and now I can’t find my solutions any more after the site has been redesigned. That is not cool!
Anyway, I am stuck on the “Removing Items Using Splice()” challenge. I did this:
function sumOfTen(arr) {
// change code below this line
for (var i = 0; i < arr.length; i++) {
if (arr[i] + arr[i+1] === 10) {
arr.splice(arr[i+1], arr.length);
}
}
// change code above this line
return arr.reduce((a, b) => a + b);
}
// do not change code below this line
console.log(sumOfTen([2, 5, 1, 5, 2, 1]));
Anyway, I am sure my splice call is wrong. I have been looking everywhere for the solution but I do not know what I am doing wrong. Any help is appreciated. Thanks!