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

12 lines
229 B
JavaScript
Raw Normal View History

export function longestWords(words) {
2022-11-03 00:45:34 +00:00
let longest = "";
for (const word of words) {
if (word.length > longest.length) {
longest = word;
}
}
return words.filter((word) => word.length === longest.length);
}