diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..15fa63c 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,32 @@ -export function sumEven(value) { - // implementar logica aqui - -} \ No newline at end of file +export function sumEven(arr=[]){ + let soma = 0 + if (arr.length == 0){ + soma = 0 + + } + else if (arr.length == 1 && arr[0] ==1){ + soma = 1 + } + else{ + for (let i = 0; i < arr.length; i++){ + if (arr[i] % 2 == 0){ + soma += arr[i] + } + } + } + + return soma +} +console.log(sumEven([])); +console.log(sumEven([1])); +console.log(sumEven([1, 2])); +console.log(sumEven([1, 2, 3])); +console.log(sumEven([1, 2, 3, 4])); +console.log(sumEven([1, 2, 3, 4, 5])); +console.log(sumEven([4, 6, 12, 5])); +console.log(sumEven([9, 234, 312, 999, 21, 2311])); +console.log(sumEven([533, 234, 23423, 32, 48876])); +console.log(sumEven([-1, 5, -10, -45])); +console.log(sumEven([-2, -7, -31])); +console.log(sumEven([-2, 20, -31])); +