refactor: funcao sumEven

This commit is contained in:
Caio Thurler 2022-10-31 14:56:24 -03:00
parent 29ae11b58c
commit 5b3f283516

View File

@ -1,12 +1,12 @@
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])
}
}
let total = 0
for (let i = 0; i < pares.length; i++) {
total += pares[i]; // adiciona o valor do indice (que aumenta com o loop) no total
}