forked from M3-Academy/challenge-algorithms-v2.0
Merge branch 'feature/10-longestWords' into development
This commit is contained in:
commit
79cbe613e8
@ -1,4 +1,13 @@
|
|||||||
export function longestWords(words) {
|
export function longestWords(words) {
|
||||||
// implementar logica aqui
|
|
||||||
|
let sortedWords = words.sort((a, b) => b.length - a.length);
|
||||||
|
let maxLength = sortedWords[0].length
|
||||||
|
let longestWords = []
|
||||||
|
|
||||||
|
for (let word of sortedWords) {
|
||||||
|
if(word.length != maxLength) break;
|
||||||
|
longestWords.push(word)
|
||||||
|
}
|
||||||
|
|
||||||
|
return longestWords;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user