2022-10-27 15:07:13 +00:00
|
|
|
export function longestWords(words) {
|
2022-10-30 12:12:36 +00:00
|
|
|
let arr, arr1;
|
2022-10-29 20:42:49 +00:00
|
|
|
let cont = 0;
|
|
|
|
let primeiro = true;
|
|
|
|
for (let i = 0; i < words.length; i++) {
|
|
|
|
|
|
|
|
if (primeiro === true) {
|
2022-10-30 12:12:36 +00:00
|
|
|
cont = words[i].length;
|
2022-10-29 20:42:49 +00:00
|
|
|
arr = " " + words[i];
|
|
|
|
primeiro = false;
|
|
|
|
} else if (words[i].length > cont) {
|
2022-10-30 12:12:36 +00:00
|
|
|
cont = words[i].length;
|
2022-10-29 20:42:49 +00:00
|
|
|
arr = " " + words[i];
|
2022-10-30 12:12:36 +00:00
|
|
|
|
2022-10-29 20:42:49 +00:00
|
|
|
} else if (words[i].length === cont) {
|
2022-10-30 12:12:36 +00:00
|
|
|
cont = words[i].length;
|
2022-10-29 20:42:49 +00:00
|
|
|
arr += " " + words[i];
|
|
|
|
}
|
|
|
|
}
|
2022-10-30 12:12:36 +00:00
|
|
|
arr1 = arr.split(" ");
|
|
|
|
arr1.shift();
|
2022-10-29 20:42:49 +00:00
|
|
|
|
|
|
|
return (arr1);
|
2022-10-27 15:07:13 +00:00
|
|
|
}
|