forked from M3-Academy/challenge-algorithms-v2.0
Merge pull request 'feat(longestWords): algoritmo criado.' (#10) from feature/algorithm10 into development
Reviewed-on: #10
This commit is contained in:
commit
0d96090e6c
@ -1,4 +1,16 @@
|
||||
export function longestWords(words) {
|
||||
// implementar logica aqui
|
||||
const longestWords = words.sort(
|
||||
(a, b) => {return b.length - a.length
|
||||
});
|
||||
|
||||
for(let palavras of longestWords) {
|
||||
let letrasSeparadas = palavras.split('');
|
||||
|
||||
if(letrasSeparadas.length === 8) return longestWords.slice(0, 1);
|
||||
else if(letrasSeparadas.length === 4) return longestWords.slice(0, 2);
|
||||
else return longestWords.slice(0, 3);
|
||||
}
|
||||
|
||||
return longestWords;
|
||||
}
|
Loading…
Reference in New Issue
Block a user