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

16 lines
396 B
JavaScript

export function longestWords(words) {
// implementar logica aqui
let long = 0;
let longWords = [];
for(let i = 0;i < words.length;i++){
if(words[i].length >= long){
long = words[i].length;
}
}
for(let j = 0;j < words.length;j++){
if(words[j].length == long){
longWords.push(words[j]);
}
}
return longWords;
}