challenge-algorithms-v2.0-w.../10-longestWords/index.js

27 lines
449 B
JavaScript
Raw Permalink Normal View History

export function longestWords(words) {
// implementar logica aqui
2022-10-31 19:55:29 +00:00
let longestLength = 0;
let longestWords = [];
words.forEach(word => {
if (longestLength < word.length) {
longestLength = word.length;
} else {
longestLength;
}
});
words.forEach(word => {
if (word.length === longestLength) {
longestWords.push(word);
}
});
return longestWords;
}