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

16 lines
434 B
JavaScript
Raw Normal View History

export function sumEven(value) {
// implementar logica aqui
2022-11-02 18:46:08 +00:00
let s = 0;
for (let i = 0; i < value.length; i++) {
if(value[i] % 2 == 0)
s += value[i]
}
return s
}
// Resultados esperados
console.log(sumEven([4, 6, 12, 5]), 22) // 22
console.log(sumEven([9, 234, 312, 999, 21, 2311]), 546) // 546
console.log(sumEven([533, 234, 23423, 32, 48876]), 49142) // 49142
console.log(sumEven([5, 4, 3, 2, 1]), 6) // 6