Created on August 1, 2020 at 6:36 pm
Updated on August 2, 2020 at 4:24 pm
Array Reduce for the Uninitiated
Hello!
The title is a pun. Let me explain:
let randoArr = [1, 2, 3, 4, 5, 6, 7, 8, 10]
let someNum = array.reduce((acc, num) => {
if(num % 2 === 0){
return acc.concat(num);
}
}, [])
This code snippet above won't work. Apparently upon the first go around, the initiated value gets wiped. Who knew? I didn't...