forked from M3-Academy/challenge-algorithms-v2.0
feat(longestwords):aplicando a função ao teste 10
This commit is contained in:
parent
6b964afa76
commit
6164b52cf0
@ -1,4 +1,18 @@
|
|||||||
export function longestWords(words) {
|
export function longestWords(words) {
|
||||||
// implementar logica aqui
|
// implementar logica aqui
|
||||||
|
let bigword = "";
|
||||||
|
|
||||||
|
words.forEach(word => {
|
||||||
|
if(word.length > bigword.length){
|
||||||
|
bigword = word
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const finalword = words.filter(word => {
|
||||||
|
if(word.length === bigword.length){
|
||||||
|
return word
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return finalword
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user