feat: implementa função das maiores palavras

This commit is contained in:
RodrigoJorge 2022-10-28 16:26:20 -03:00
parent 96de2bd2c3
commit 2fbbf551a0

View File

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