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

15 lines
260 B
JavaScript
Raw Normal View History

export function sumEven(value) {
// implementar logica aqui
2022-10-29 20:47:46 +00:00
let soma = 0
if(value.length == 0) return 0
for (let i = 0; i < value.length; i++) {
if(value[i] % 2 === 0) {
soma += value[i]
}
}
return soma
2022-10-29 20:47:46 +00:00
}
sumEven([1, 2, 3, 4, 5])