From e4062844a516371c78fd8810af8cad6aa3c9360d Mon Sep 17 00:00:00 2001 From: Douglas Nobrega Date: Mon, 31 Oct 2022 16:38:39 -0300 Subject: [PATCH] desafio 10 concluido --- 10-longestWords/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..134e01e 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,10 @@ export function longestWords(words) { - // implementar logica aqui - -} \ No newline at end of file + // implementar logica aqui + let maiorPalavra = ""; + for (let i = 0; i < words.length; i++) { + if (words[i].length > maiorPalavra.length) { + maiorPalavra = words[i]; + } + } + return words.filter((i) => i.length === maiorPalavra.length); +}