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

13 lines
357 B
JavaScript

export function longestWords(words) {
// implementar logica aqui
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;
}, []);
}