From 146c2a9cc322e860e0e9ee78ea4d72a403c63b91 Mon Sep 17 00:00:00 2001 From: MarcelloMartins Date: Mon, 31 Oct 2022 18:28:35 -0300 Subject: [PATCH] feat(10-longestWords):completead tenth challenge --- 10-longestWords/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..a5dc5c1 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,12 @@ export function longestWords(words) { // implementar logica aqui - + let lista = []; + words.forEach(palavra => { + if(!lista[0] || lista[0].length < palavra.length){ + lista = [palavra] + } else if(lista[0].length == palavra.length){ + lista.push(palavra) + } + }); + return lista; } \ No newline at end of file