forked from M3-Academy/challenge-algorithms-v2.0
17 lines
444 B
JavaScript
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;
|
|
} |