From 967448340ad8b3ff35507b3d4d919ecf3d8c3033 Mon Sep 17 00:00:00 2001 From: Caroline Moran Date: Fri, 28 Oct 2022 08:02:20 -0400 Subject: [PATCH] =?UTF-8?q?feat(longestWords):=20fazendo=20func=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 10-longestWords/index.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..7981158 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,17 @@ export function longestWords(words) { - // implementar logica aqui - -} \ No newline at end of file + // implementar logica aqui + let max_string_size = 0; + let big_string_list = []; + + for (let string of words) { + const string_size = string.length; + + if (string_size > max_string_size) { + big_string_list = [string]; + max_string_size = string_size; + } else if (string_size == max_string_size) { + big_string_list.push(string); + } + } + return big_string_list; +}