2022-10-27 15:07:13 +00:00
|
|
|
export function longestWords(words) {
|
2022-11-02 16:41:20 +00:00
|
|
|
// implementar logica aqui
|
2022-11-02 20:30:31 +00:00
|
|
|
|
2022-11-02 16:41:20 +00:00
|
|
|
const lengthArray = []
|
|
|
|
|
|
|
|
words.forEach(element => {
|
2022-11-02 20:30:31 +00:00
|
|
|
lengthArray.push([element, element.length])
|
2022-11-02 16:41:20 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
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
|
2022-11-02 20:30:31 +00:00
|
|
|
}
|