feat: solucao sumEven

This commit is contained in:
Rafael Sampaio de Oliveira 2022-10-28 10:49:04 -03:00
parent c6f6df9c59
commit bb9ac73956

View File

@ -1,4 +1,15 @@
export function sumEven(value) {
// implementar logica aqui
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;
}
}