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