2022-10-27 15:07:13 +00:00
|
|
|
export function sumEven(value) {
|
|
|
|
// implementar logica aqui
|
2022-10-30 22:45:47 +00:00
|
|
|
let pares = []
|
|
|
|
for (let i = 0; i < value.length; i++) {
|
|
|
|
if (value[i] % 2 == 0) {
|
|
|
|
pares.push(value[i])
|
|
|
|
}
|
|
|
|
}
|
2022-10-31 17:56:24 +00:00
|
|
|
let total = 0
|
2022-10-30 22:45:47 +00:00
|
|
|
for (let i = 0; i < pares.length; i++) {
|
|
|
|
total += pares[i]; // adiciona o valor do indice (que aumenta com o loop) no total
|
|
|
|
}
|
|
|
|
value = [];
|
|
|
|
return total; // torna value = total
|
|
|
|
}
|