From adbda1f6363a9145891965548b6d97df51fde480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cain=C3=A3=20Milech?= Date: Fri, 28 Oct 2022 23:46:59 -0300 Subject: [PATCH] feat(longestWords): implementa function --- 10-longestWords/index.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..edaa5ec 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,22 @@ export function longestWords(words) { - // implementar logica aqui + + let maior = ''; + let maiores = []; + + for(let palavra of words){ + if(palavra.length > maior.length){ + maior = palavra; + } + } + + let caracteres = maior.length; + + for(let palavra of words){ + if(caracteres === palavra.length){ + maiores.push(palavra); + } + } + + return maiores; } \ No newline at end of file