diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..deef95f 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,27 @@ export function longestWords(words) { - // implementar logica aqui - + // implementar logica aqui + const lengthArray = [] + + words.forEach(element => { + lengthArray.push([element, element.length ]) + }) + + + let res = ['', 0] + + lengthArray.forEach(array => { + if (res[1] < array[1]) { + res = array + } + }) + + const AllLongestWords = [] + + lengthArray.forEach(array => { + if (res[1] == array[1]) { + AllLongestWords.push(array[0]) + } + }) + + return AllLongestWords } \ No newline at end of file