forked from M3-Academy/challenge-algorithms-v2.0
Merge pull request 'feat(longestWords): Adicionando algoritmo que retorna uma lista com as palavras mais longas de uma lista de palavras.' (#10) from feature/longestWords into development
Reviewed-on: #10
This commit is contained in:
commit
88b09139a4
@ -1,4 +1,15 @@
|
||||
export function longestWords(words) {
|
||||
// implementar logica aqui
|
||||
let vetWords = [];
|
||||
|
||||
for (let index = 0; index < words.length; index++) {
|
||||
if (vetWords.length === 0) {
|
||||
vetWords.push(words[index]);
|
||||
} else if (vetWords[0].length < words[index].length) {
|
||||
vetWords = [];
|
||||
vetWords.push(words[index]);
|
||||
} else if (vetWords[0].length === words[index].length) {
|
||||
vetWords.push(words[index]);
|
||||
}
|
||||
}
|
||||
return vetWords;
|
||||
}
|
Loading…
Reference in New Issue
Block a user