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

13 lines
295 B
JavaScript

export function longestWords(words) {
// implementar logica aqui
return words.reduce((r, s, i) => {
if (!i || r[0].length < s.length) {
return [s];
}
if (r[0].length === s.length) {
r.push(s);
}
return r;
}, []);
}