I would like to know how to loop through the while loop an x number of times over?
This is my while loop where it counts 200 10 times, what I want to do is keep looping that count another 90 times for example:
while (go) {
data = getRecordsByPage(i,200,token,module);
if (Number(data.info.count) < 200) {
go = false;
};
if (i == 0) {
go = false;
continue
}
while(go = false)
{
Utilities.sleep(10000)
}
if(Utilities.sleep == 10000)
{
go = true;
}
}
rows = Number(rows) Number(data.info.count);
i ;
Logger.log(rows)
}
I also have another while loop in there to give a 10 sec time-out before the loop starts over again to do another count.
CodePudding user response:
I check your previous post to get some context about your issue and I think what you are trying to do is to create a script that execute a commands every 10 iterations and you want to repeat it 90 times.
Here I added for loop
and while loop
that prints in every 10 iterations 90 times.
While loop:
function whileLoopCount(){
var x = 1
while (x <= 900){
if((x % 10) == 0){
Logger.log(x);
}
x ;
}
}
For Loop:
function forLoopCount(){
for (var i = 1; i <= 900; i ){
if((i % 10) == 0){
Logger.log(i);
}
}
}
Let me know if my understanding of your issue is correct.
Reference:
CodePudding user response:
function ttttttttt() {
let x = 10;
Logger.log([...Array.from(new Array(x).keys())].map(e => e));//[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
let a = [];
while(x--) {
a.push(x);
}
Logger.log(a);//[9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0]
}