forked from M3-Academy/challenge-algorithms-v2.0
18 lines
426 B
JavaScript
18 lines
426 B
JavaScript
export function longestWords(words) {
|
|
let longestWord = "";
|
|
let longestWordsArray = [];
|
|
for (let i = 0; i < words.length; i++) {
|
|
if (words[i].length >= longestWord.length) {
|
|
longestWord = words[i];
|
|
}
|
|
}
|
|
for (let i = 0; i < words.length; i++) {
|
|
if (words[i].length == longestWord.length) {
|
|
longestWordsArray.push(words[i]);
|
|
}
|
|
}
|
|
|
|
return longestWordsArray;
|
|
// implementar logica aqui
|
|
}
|