From 932ab42fa0814ab894b0f2d8086f03be3ba60b4b Mon Sep 17 00:00:00 2001 From: Adilson Fernando Date: Sat, 29 Oct 2022 17:33:13 -0300 Subject: [PATCH] feat: 10-lista-palavras-mais-longas --- 10-longestWords/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..fdad52d 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,12 @@ 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); + }