feat(longestWords): Implementacao da funcao longestWords()

This commit is contained in:
Wellington Duarte Santos 2022-11-01 09:38:13 -03:00
parent 8300a31ec7
commit 56904fc642

View File

@ -1,4 +1,19 @@
export function longestWords(words) {
// implementar logica aqui
let maiorPalavra = 0;
let maiores = [];
for (let i = 0; i < words.length; i++){
if(words[i].length > maiorPalavra){
maiorPalavra = words[i].length
}
}
for (let i = 0; i < words.length; i++){
if(words[i].length === maiorPalavra){
maiores.push(words[i]);
}
}
return maiores;
}