using reduce on even values of an array

PHOTO EMBED

Fri Apr 21 2023 21:14:27 GMT+0000 (Coordinated Universal Time)

Saved by @thecowsays #javascript

let numbers = [5, 10, 12, 13, 17, 20, 21, 28];

let sumOfEvens = numbers.reduce((total,active) => {
    if (active % 2 === 0) {
        return active + total;
    console.log (`checking...even!`);
    }
    return total
}
, 0);

console.log (sumOfEvens);
content_copyCOPY