challenge-algorithms-v2.0-a.../10-longestWords/index.js
2022-11-02 15:00:01 -03:00

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;
}