forked from M3-Academy/challenge-algorithms-v2.0
14 lines
321 B
JavaScript
14 lines
321 B
JavaScript
export function longestWords(words) {
|
|
const longestWordsArray = [];
|
|
let tamanhoWord = 0;
|
|
|
|
words.forEach((word) => {
|
|
if (word.length > tamanhoWord) tamanhoWord = word.length;
|
|
});
|
|
words.forEach((word) => {
|
|
if (word.length == tamanhoWord) longestWordsArray.push(word);
|
|
});
|
|
|
|
return longestWordsArray;
|
|
}
|