From 46330609358ca196e1cc54fbb31ead5c0d9feb23 Mon Sep 17 00:00:00 2001 From: Vinicius Date: Wed, 2 Nov 2022 18:31:35 -0200 Subject: [PATCH] feature(maxValue): cria funcao que encontra maior elemento de um array --- 03-maxValue/index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..c8c4066 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,15 @@ export function maxValue(values) { // implementar logica aqui - -} \ No newline at end of file + let maior = -1; + + if (values.length === 0) { + maior = 0; + } else { + for (let i in values) { + if (values[i] > maior) { + maior = values[i]; + } + } + } + return maior; +}