feat(longestWords): Finaliza algoritmo
This commit is contained in:
parent
e9f6faa988
commit
c7e515ec35
@ -1,4 +1,26 @@
|
||||
export function longestWords(words) {
|
||||
// implementar logica aqui
|
||||
|
||||
}
|
||||
|
||||
let longestLength = 0;
|
||||
let longestWords = [];
|
||||
|
||||
words.forEach(word => {
|
||||
if (longestLength < word.length) {
|
||||
longestLength = word.length;
|
||||
} else {
|
||||
longestLength;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
words.forEach(word => {
|
||||
if (word.length === longestLength) {
|
||||
longestWords.push(word);
|
||||
}
|
||||
});
|
||||
|
||||
return longestWords;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user