challenge-algorithms-v2.0-P.../10-longestWords/index.js
2022-11-02 12:58:37 -03:00

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
}