diff --git a/10-longestWords/index.js b/10-longestWords/index.js index 904db4e..f63dcea 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,16 +1,16 @@ export function longestWords(words) { // implementar logica aqui - let comp = 0; + let maiorTamanho = 0; + let i = 0; let resultado = []; for (i in words) { - if (comp < words[i].length) { - comp = words[i].length; - resultado.push(words[i]); + if (words[i].length > maiorTamanho) { + maiorTamanho = words[i].length; } } - if (resultado.length > 1) { - if (resultado[0].length < resultado[1].length) { - resultado.shift(); + for (i in words) { + if (words[i].length == maiorTamanho) { + resultado.push(words[i]); } }