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

10 lines
259 B
JavaScript

export function longestWords(words) {
let longWord = "";
let word;
for(word of words) {
if (word.length > longWord.length){
longWord = word;
}
}
return words.filter((word) => word.length === longWord.length);
}