From 77da09fea67dd382c574292ef56995fa8f1bff81 Mon Sep 17 00:00:00 2001 From: Caio Thurler Date: Sun, 30 Oct 2022 19:37:14 -0300 Subject: [PATCH] feat: funcao sum --- 06-sum/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..ebb7482 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,8 @@ export function sum(values) { // implementar logica aqui - + let total = 0 + for (let i = 0; i < values.length; i++) { + total += values[i]; // adiciona o valor do indice (que aumenta com o loop) no total + } + return total // torna values = total } \ No newline at end of file