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

16 lines
327 B
JavaScript
Raw Normal View History

export function sumEven(value) {
// implementar logica aqui
2022-10-28 11:42:09 +00:00
const arr = [];
for (let index = 0; index < value.length; index++) {
const element = value[index];
if (element % 2 == 0) {
arr.push(element);
}
}
function add(a, b) {
return a + b;
}
var soma = arr.reduce(add, 0);
return soma;
}