From 3f1d45d072e44bc1e46c90651dfed49b1bc20c92 Mon Sep 17 00:00:00 2001 From: Thiago Bronisio <86695254+ThiagoBronisio@users.noreply.github.com> Date: Tue, 1 Nov 2022 02:24:07 -0300 Subject: [PATCH] feat(challenge): desafio longestWords finalizado --- 10-longestWords/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..4b54260 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,16 @@ export function longestWords(words) { // implementar logica aqui - + let arr = words.sort(function (a, b) { + return b.length - a.length; + }) + let firstChar = arr[0]; + let arrayVazia = []; + for(let i = 0; i < arr.length; i++){ + if(arr[i].length === firstChar.length){ + arrayVazia.push(arr[i]); + continue; + } + return arrayVazia; + } + return words; } \ No newline at end of file -- 2.34.1