Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

278
Views
Google App Scritpt: How to do a while loop so that the iteration keeps going until the last number is reached?

Good Day,

I have a while loop that iterates 5 times and loops through 200 rows every iteration. Is there a way to have the while loop keep going until it reaches its last row? This is for a row count.

Here is the current while loop I have for the row count so far:

function testMe(a) {
  

  if(a == 5) {
    return JSON.parse('{"info":{"count":"3"}}');
  }
  else {
    return JSON.parse('{"info":{"count":"200"}}');
  }
}
function rowcount ()
{ 
  var rows = 0;
  var go = true;
  var i = 1;
  var data;
  while (go) {
    data = testMe(i);
    if (Number(data.info.count) < 200) {
      go = false;
    };
    rows = Number(rows) + Number(data.info.count);
    i++;
  }
  Logger.log(rows);
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use nested loops, such that the inner loop runs while the outer loop holds, and then breaks out of the outer loop when the last time row has been completed. Your current loop should be your inner loop, the outer loop should be like

while (rows <= 200){
     while (go) {
    data = testMe(i);
    if (Number(data.info.count) < 200) {
      go = false;
    };
    rows = Number(rows) + Number(data.info.count);
    i++;
  }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!