forked from M3-Academy/challenge-algorithms-v2.0
20 lines
364 B
JavaScript
20 lines
364 B
JavaScript
export function longestWords(words) {
|
|
// implementar logica aqui
|
|
let long = ''
|
|
|
|
const longest = words.map((word) => {
|
|
if(word.length > long.length) {
|
|
long = word;
|
|
}
|
|
|
|
return word
|
|
|
|
}).filter((word) => {
|
|
if(word.length === long.length) {
|
|
return word;
|
|
}
|
|
});
|
|
|
|
return longest
|
|
|
|
} |