forked from M3-Academy/challenge-algorithms-v2.0
16 lines
418 B
JavaScript
16 lines
418 B
JavaScript
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;
|
|
} |