feat(10-longestWords): adiciona função

This commit is contained in:
Emerson Fully 2022-11-01 22:52:13 -03:00
parent 0eecc63f1c
commit 3c5165a358

View File

@ -1,4 +1,19 @@
export function longestWords(words) {
// implementar logica aqui
}
const longestWords = [];
let longest = '';
for (let i = 0; i < words.length; i++) {
if (words[i].length > longest.length) {
longest = words[i];
}
}
for (let i = 0; i < words.length; i++) {
if (words[i].length === longest.length) {
longestWords.push(words[i]);
}
}
return longestWords;
}