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

12 lines
354 B
JavaScript
Raw Permalink Normal View History

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