forked from M3-Academy/challenge-algorithms-v2.0
feat(longestWords): desenvolvimento da funcao
This commit is contained in:
parent
1d5a1c0007
commit
04c26faffd
@ -1,4 +1,15 @@
|
|||||||
export function longestWords(words) {
|
export function longestWords(words) {
|
||||||
// implementar logica aqui
|
// implementar logica aqui
|
||||||
|
let maior = 0;
|
||||||
|
for (const palavra of words){
|
||||||
|
if (palavra.length > maior)
|
||||||
|
maior = palavra.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
const arr = [];
|
||||||
|
words.map(element=>{
|
||||||
|
if (element.length === maior)
|
||||||
|
arr.push(element);
|
||||||
|
})
|
||||||
|
return arr;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user