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:
Savio Carvalho Moraes 2022-10-30 18:33:37 +00:00
commit 88b09139a4

View File

@ -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;
}