From 1fe9d7fb96a1a445ac26c5fc8706c4917ed42872 Mon Sep 17 00:00:00 2001 From: Sabrina Miranda Date: Fri, 28 Oct 2022 14:55:31 -0300 Subject: [PATCH] feat: Implementa Desafio 2.3 --- 03-maxValue/index.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..cbc3564 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,18 @@ export function maxValue(values) { - // implementar logica aqui - + let valores = [...values]; + let maiorValor = valores[0]; + + if(valores.length === 0) { + maiorValor = 0; + }else { + for(let i = 0 ; i < valores.length ; i++) { + let valor = valores[i]; + + if(valor > maiorValor) { + maiorValor = valor; + } + } + } + + return maiorValor; } \ No newline at end of file