feat: funcao sumEven

This commit is contained in:
Caio Thurler 2022-10-30 19:45:47 -03:00
parent 77da09fea6
commit 293b56673c

View File

@ -1,4 +1,15 @@
export function sumEven(value) {
// implementar logica aqui
}
let total = 0
let pares = []
for (let i = 0; i < value.length; i++) {
if (value[i] % 2 == 0) {
pares.push(value[i])
}
}
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
}