diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..377fa39 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,24 @@ export function longestWords(words) { - // implementar logica aqui - -} \ No newline at end of file + + let letra = words + let tamanho = 0 + let maximo = [' '] + + for (let i = 0; i < letra.length; i++) { + if (letra[i].length >= tamanho) { + tamanho = letra[i].length + if (maximo[maximo.length - 1].length < letra[i].length) { + maximo = [] + maximo.push(letra[i]) + } + else { + maximo = [...maximo, letra[i]] + } + } + } + return [...maximo] +} + + + +