From 1335638115b955545f25847aee102d8434133783 Mon Sep 17 00:00:00 2001 From: MateusLopes Date: Wed, 2 Nov 2022 20:16:40 -0300 Subject: [PATCH] feat(longestWords): algoritmo concluido --- 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..235ada1 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,11 @@ export function longestWords(words) { - // implementar logica aqui - + let longest = ''; + + for (const word of words) { + if (word.length > longest.length) { + longest = word; + } + } + + return words.filter((word) => word.length === longest.length); } \ No newline at end of file