forked from M3-Academy/challenge-algorithms-v2.0
feat(longestWords): algoritmo criado.
This commit is contained in:
parent
e155699ab6
commit
be99feb845
@ -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