From cfdec8e85dd9c226156adcccd3c236b1d5d46516 Mon Sep 17 00:00:00 2001 From: Humberto Ferro Date: Mon, 31 Oct 2022 10:11:20 -0300 Subject: [PATCH] feat: criar algoritmo que retorne as palavras longas de uma lista de palavras --- 10-longestWords/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..d17f723 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,14 @@ export function longestWords(words) { // implementar logica aqui - + let newArr = []; + let long = 0; + words.forEach(function(element){ + if(element.length > long){ + long = element.length + } + }); + newArr = words.filter(element => + element.length == long + ); + return newArr; } \ No newline at end of file