From 176d485260236a9ff882f0d76548004e36cdf927 Mon Sep 17 00:00:00 2001 From: Patrick Date: Sun, 30 Oct 2022 20:53:26 -0300 Subject: [PATCH] feat: algoritmo 6 e 7 --- 06-sum/index.js | 8 ++++++-- 07-sumEven/index.js | 12 +++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..8914608 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,8 @@ export function sum(values) { + let soma = 0; + for (let i = 0; i < values.length; i++) { + soma += values[i]; + } + return soma; // implementar logica aqui - -} \ No newline at end of file +} diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..998bbc0 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,10 @@ export function sumEven(value) { - // implementar logica aqui - -} \ No newline at end of file + let soma = 0; + for (let i = 0; i <= value.length; i++) { + if (value[i] % 2 === 0) { + soma += value[i]; + } + } + return soma; + // implementar logica aqui if (variavel % 2 !== 0) +}