2022-10-27 15:07:13 +00:00
|
|
|
export function longestWords(words) {
|
|
|
|
// implementar logica aqui
|
2022-10-29 04:23:46 +00:00
|
|
|
if (words.length == 0)
|
|
|
|
return console.log('Escreva as palavras a serem consultar');
|
|
|
|
else {
|
|
|
|
let cont = words[0].length;
|
|
|
|
for (let i = 1; i < words.length; i++) {
|
|
|
|
if (cont < words[i].length)
|
|
|
|
cont = words[i].length;
|
|
|
|
}
|
|
|
|
let longest = [];
|
|
|
|
for (let j = 0; j < words.length; j++) {
|
|
|
|
if (cont == words[j].length)
|
|
|
|
longest.push(words[j]);
|
|
|
|
}
|
|
|
|
return longest;
|
|
|
|
}
|
2022-10-27 15:07:13 +00:00
|
|
|
|
|
|
|
}
|