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

18 lines
340 B
JavaScript
Raw Permalink Normal View History

export function longestWords(words) {
// implementar logica aqui
2022-10-28 13:51:39 +00:00
let big = "";
2022-10-28 13:51:39 +00:00
words.forEach(word => {
if(word.length > big.length){
big = word
}
});
const result = words.filter(word => {
if(word.length === big.length){
return word
}
});
return result
}