12 lines
354 B
JavaScript
12 lines
354 B
JavaScript
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;
|
|
}, []);
|
|
} |