forked from M3-Academy/challenge-algorithms-v2.0
13 lines
357 B
JavaScript
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;
|
|
}, []);
|
|
} |