forked from M3-Academy/challenge-algorithms-v2.0
feat: finalizado longestWords
This commit is contained in:
parent
b4852810c4
commit
d49e9fbdf8
@ -1,4 +1,20 @@
|
|||||||
export function longestWords(words) {
|
export function longestWords(words) {
|
||||||
// implementar logica aqui
|
// 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
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user