forked from M3-Academy/challenge-algorithms-v2.0
feat(challenge): desafio longestWords finalizado
This commit is contained in:
parent
50a435b901
commit
3f1d45d072
@ -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;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user