forked from M3-Academy/challenge-algorithms-v2.0
feat(sumEven): fazendo funcão
This commit is contained in:
parent
755ff029e8
commit
b797ec9a59
@ -1,4 +1,15 @@
|
||||
export function sumEven(value) {
|
||||
// implementar logica aqui
|
||||
|
||||
const arr = [];
|
||||
for (let index = 0; index < value.length; index++) {
|
||||
const element = value[index];
|
||||
if (element % 2 == 0) {
|
||||
arr.push(element);
|
||||
}
|
||||
}
|
||||
function add(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
var soma = arr.reduce(add, 0);
|
||||
return soma;
|
||||
}
|
Loading…
Reference in New Issue
Block a user