From 431d85fa5e24c75e62ab7c4fb315b2b7a0a2e807 Mon Sep 17 00:00:00 2001 From: Marcela Mathias Date: Wed, 2 Nov 2022 21:45:34 -0300 Subject: [PATCH] add longestWords logic correct --- 10-longestWords/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..370cffc 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 (const word of words) { + if (word.length > longest.length) { + longest = word; + } + } + + return words.filter((word) => word.length === longest.length); +}