From 2fbbf551a0235295db19e7bc0f37e477d32a7b86 Mon Sep 17 00:00:00 2001 From: RodrigoJorge Date: Fri, 28 Oct 2022 16:26:20 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20implementa=20fun=C3=A7=C3=A3o=20das=20m?= =?UTF-8?q?aiores=20palavras?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 10-longestWords/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..9f6b477 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,16 @@ export function longestWords(words) { // implementar logica aqui - + let maior = 0; + let maioresPalavras = []; + for(let i = 0;i < words.length;i++){ + if(words[i].length >= maior){ + maior = words[i].length; + } + } + for(let j = 0;j < words.length;j++){ + if(words[j].length == maior){ + maioresPalavras.push(words[j]); + } + } + return maioresPalavras; } \ No newline at end of file