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

13 lines
357 B
JavaScript
Raw Permalink Normal View History

export function longestWords(words) {
// implementar logica aqui
2022-11-02 15:48:51 +00:00
return words.reduce((longest, sentence, i) => {
if (!i || longest[0].length < sentence.length) {
return [sentence];
}
if (longest[0].length === sentence.length) {
longest.push(sentence);
}
return longest;
}, []);
}