From 75402916a67317713b356d327b23b4e6c9f7e99c Mon Sep 17 00:00:00 2001 From: ueberjames Date: Fri, 28 Oct 2022 20:54:12 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20implementa=C3=A7=C3=A3o=20de=20algoritm?= =?UTF-8?q?o=20que=20retorne=20a=20soma=20de=20todos=20os=20n=C3=BAmeros?= =?UTF-8?q?=20de=20um=20array?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 06-sum/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..b516f0f 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,17 @@ export function sum(values) { // implementar logica aqui + let soma = 0; + let numbers = values + + if (numbers == `${[]}`) { + + return 0; + } + else{ + for(let i=0; i< numbers.length; i++){ + soma = soma + numbers[i]; + } + return soma + } + } -} \ No newline at end of file