forked from M3-Academy/challenge-algorithms-v2.0
feat(challenge-10): completed challenge
This commit is contained in:
parent
04bbc0e63b
commit
ecf880dc2f
@ -1,4 +1,21 @@
|
||||
export function longestWords(words) {
|
||||
// implementar logica aqui
|
||||
// implementar logica aqui
|
||||
if (words.length === 0 || !words) return 0;
|
||||
|
||||
let wordLengthMax = 0;
|
||||
let wordsList = [];
|
||||
|
||||
for (let word of words) {
|
||||
if (word.length >= wordLengthMax) {
|
||||
wordLengthMax = word.length;
|
||||
}
|
||||
}
|
||||
|
||||
for (let word of words) {
|
||||
if (wordLengthMax === word.length) {
|
||||
wordsList.push(word);
|
||||
}
|
||||
}
|
||||
|
||||
return wordsList;
|
||||
}
|
Loading…
Reference in New Issue
Block a user