From 9b60bfe0286a4035acd4317e6a3fa4c70da1a28f Mon Sep 17 00:00:00 2001 From: Matheus Date: Wed, 2 Nov 2022 13:32:48 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20cria=C3=A7=C3=A3o=20da=20resposta=20=20?= =?UTF-8?q?do=2010-longestWords?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 10-longestWords/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..58b8a0f 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,17 @@ export function longestWords(words) { // implementar logica aqui - + + let loop = 0; + let newWords = []; + for (let index = 0; index < words.length; index++) { + if (words[index].length > loop) { + loop = words[index].length + } + } + for (let index = 0; index < words.length; index++) { + if (loop === words[index].length) { + newWords.push(words[index]) + } + } + return newWords; } \ No newline at end of file