From b5637169b3b822f24445895dd7d9b1c36d29d279 Mon Sep 17 00:00:00 2001 From: MateusLopes Date: Wed, 2 Nov 2022 20:13:46 -0300 Subject: [PATCH] feat(sum): algoritmo concluido --- 06-sum/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..deddc64 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,8 @@ export function sum(values) { - // implementar logica aqui - -} \ No newline at end of file + // implementar logica aqui + let valorInicial = 0 + return values.reduce( + (valorAnterior, valorAtual) => valorAnterior + valorAtual, + valorInicial + ) +}