From 1acd1d9c07f573cbed00b49e14dcc1be544e482a Mon Sep 17 00:00:00 2001 From: Ramon Dias Ferreira Date: Wed, 2 Nov 2022 15:16:08 -0300 Subject: [PATCH] =?UTF-8?q?feat(longestWords):=20la=C3=A7o=20com=20if=20co?= =?UTF-8?q?ndicional=20para=20verifica=C3=A7=C3=A3o=20do=20length=20das=20?= =?UTF-8?q?palavras?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 10-longestWords/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..5a0b288 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,11 @@ export function longestWords(words) { // implementar logica aqui - -} \ No newline at end of file + let longest = ''; + for (let word of words) { + if (word.length > longest.length) { + longest = word; + } + } + + return words.filter((word) => word.length === longest.length); + }