feat(challenge): desafio longestWords finalizado #10

Merged
Thiago.bronisio merged 1 commits from feature/longestWords into master 2022-11-01 05:24:36 +00:00

View File

@ -1,4 +1,16 @@
export function longestWords(words) { export function longestWords(words) {
// implementar logica aqui // 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;
} }