From aab1f4115e7eb51dd6785946ab21e92b8ea2c348 Mon Sep 17 00:00:00 2001 From: tiago rodrigues Date: Wed, 2 Nov 2022 20:20:35 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20finalizando=20o=20D=C3=A9cimo=20Exerc?= =?UTF-8?q?=C3=ADcio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 10-longestWords/index.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index 7abd7b7..8c0985c 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,6 +1,24 @@ export function longestWords(words) { // implementar logica aqui - + let maior = ""; + //usar forEach + words.forEach(comparador => { + if (comparador.length > maior.length) { + maior = comparador + + } + + }); + + const resultado = words.filter(comparador => { + if (comparador.length === maior.length) { + + return comparador; + + } + }); + + return resultado; }