forked from M3-Academy/challenge-algorithms-v2.0
16 lines
425 B
JavaScript
16 lines
425 B
JavaScript
export function longestWords(words) {
|
|
let vetWords = [];
|
|
|
|
for (let index = 0; index < words.length; index++) {
|
|
if (vetWords.length === 0) {
|
|
vetWords.push(words[index]);
|
|
} else if (vetWords[0].length < words[index].length) {
|
|
vetWords = [];
|
|
vetWords.push(words[index]);
|
|
} else if (vetWords[0].length === words[index].length) {
|
|
vetWords.push(words[index]);
|
|
}
|
|
}
|
|
return vetWords;
|
|
}
|