Merge pull request 'feat(challenge): desafio longestWords finalizado' (#10) from feature/longestWords into master

Reviewed-on: #10
This commit is contained in:
Thiago Bronisio Damascena 2022-11-01 05:24:35 +00:00
commit cc86af3000

View File

@ -1,4 +1,16 @@
export function longestWords(words) {
// implementar logica aqui
let arr = words.sort(function (a, b) {
return b.length - a.length;
})
let firstChar = arr[0];
let arrayVazia = [];
for(let i = 0; i < arr.length; i++){
if(arr[i].length === firstChar.length){
arrayVazia.push(arr[i]);
continue;
}
return arrayVazia;
}
return words;
}