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

10 lines
259 B
JavaScript
Raw Normal View History

export function longestWords(words) {
2022-11-02 20:14:55 +00:00
let longWord = "";
let word;
for(word of words) {
if (word.length > longWord.length){
longWord = word;
}
}
return words.filter((word) => word.length === longWord.length);
}