challenge-algorithms-v2.0-r.../07-sumEven/index.js

16 lines
321 B
JavaScript
Raw Normal View History

export function sumEven(value) {
// implementar logica aqui
2022-10-28 13:49:04 +00:00
let pair = (x) => x % 2 === 0;
if (value.length === 0) {
return 0;
} else if (value % 2 === 1) {
return 0;
} else {
let sumOfPairs = value
.filter(pair)
.reduce((pairs, number) => pairs + number);
return sumOfPairs;
}
}