feature: resolve exercício 10-longestWords

This commit is contained in:
Andrea Matsunaga 2022-11-01 14:01:13 -03:00
parent 588770824a
commit 8a048120da

View File

@ -1,4 +1,13 @@
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;
}