forked from M3-Academy/challenge-algorithms-v2.0
feat(challenge-7): completed challenge
This commit is contained in:
parent
e650ec9d21
commit
8d7b786b23
@ -1,4 +1,13 @@
|
||||
export function sumEven(value) {
|
||||
// implementar logica aqui
|
||||
if (value.length === 0 || !value) return 0;
|
||||
|
||||
// acc é abreviação de accumulator(acumulador)
|
||||
return value.reduce((acc, number) => {
|
||||
if (number % 2 === 0) {
|
||||
return (acc += number);
|
||||
}else {
|
||||
return acc += 0
|
||||
}
|
||||
}, 0);
|
||||
}
|
Loading…
Reference in New Issue
Block a user