challenge-algorithms-v2.0-m.../10-longestWords/index.js

17 lines
444 B
JavaScript

export function longestWords(words) {
// implementar logica aqui
let loop = 0;
let newWords = [];
for (let index = 0; index < words.length; index++) {
if (words[index].length > loop) {
loop = words[index].length
}
}
for (let index = 0; index < words.length; index++) {
if (loop === words[index].length) {
newWords.push(words[index])
}
}
return newWords;
}