From 8a048120dad7650755028eee16dd5a65956ca687 Mon Sep 17 00:00:00 2001 From: Andrea Matsunaga Date: Tue, 1 Nov 2022 14:01:13 -0300 Subject: [PATCH] =?UTF-8?q?feature:=20resolve=20exerc=C3=ADcio=2010-longes?= =?UTF-8?q?tWords?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 10-longestWords/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..99146ea 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,13 @@ export function longestWords(words) { - // implementar logica aqui - + + let sortedWords = words.sort((a, b) => b.length - a.length); + let maxLength = sortedWords[0].length + let longestWords = [] + + for (let word of sortedWords) { + if(word.length != maxLength) break; + longestWords.push(word) + } + + return longestWords; } \ No newline at end of file