I wonder if there is a way to optimise the time that script takes to execute. I tried with yield but not sure if its a proper option to handle this case.
let enter = [1, 2, 3, 4, 5];
let result = 0;
let counter = 0;
while (counter < 3) {
result++;
if (result % enter[0] == 0) {
counter++;
}
if (result % enter[1] == 0) {
counter++;
}
if (result % enter[2] == 0) {
counter++;
}
if (result % enter[3] == 0) {
counter++;
}
if (result % enter[4] == 0) {
counter++;
}
if (counter < 3) {
counter = 0;
}
}
console.log(result);