27 lines
462 B
JavaScript
27 lines
462 B
JavaScript
export function longestWords(words) {
|
|
// 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
|
|
} |