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

234
Views
Javascript: how to add the last number on each passing iteration?

Good Day,

How do you add the last row count number onto every passing, let's say the function repeatloop() code below passing 2000 for 1 pass, how do you add 2000 to each passing that happens so if the passing is 10 that would == to 20 000 at the end of 10 passing, please see my code below:

function rowcount()
{ 
 var token = getAccessToken();
 var module = "sHistory";
 var rows = 0;
 var go = true;
 var i = 1;
 var data;
 
  
  while (go) {
    //Utilities.sleep(10000)
   data = getRecordsByPage(i,200,token,module);
   
   if (Number(data.info.count) < 200) {
     go = false;
   };
   if ((i%10) == 0) {
      go = false; 
   }
   rows = Number(rows) + Number(data.info.count);
     i++;
  
     Logger.log("rowcount " + rows)
     }
     return rows
  }
 
 
function repeatloop()
{
 for(var i = 1; i <= 93; i++)
     {
       Utilities.sleep(10000)
       Logger.log(i);
       Logger.log(rowcount());
     }
     return rowcount();
}

So currently the output is doing this:

2:20:15 AM Info 1.0 2:20:16 AM Info 200.0 2:20:16 AM Info 400.0 2:20:17 AM Info 600.0 2:20:17 AM Info 800.0 2:20:17 AM Info 1000.0 2:20:18 AM Info 1200.0 2:20:18 AM Info 1400.0 2:20:18 AM Info 1600.0 2:20:19 AM Info 1800.0 2:20:19 AM Info 2000.0 2:20:19 AM Info 2000.0 2:20:19 AM Info 0.0 2:20:29 AM Info 2.0 2:20:30 AM Info 200.0 2:20:31 AM Info 400.0 2:20:31 AM Info 600.0 2:20:31 AM Info 800.0 2:20:32 AM Info 1000.0 2:20:32 AM Info 1200.0 2:20:32 AM Info 1400.0 2:20:33 AM Info 1600.0 2:20:33 AM Info 1800.0 2:20:33 AM Info 2000.0 2:20:33 AM Info 2000.0 2:20:34 AM Info 2000.0 2:20:34 AM Info 200.0 2:20:34 AM Info 400.0 2:20:35 AM Info 600.0 2:20:35 AM Info 800.0 2:20:35 AM Info 1000.0 2:20:36 AM Info 1200.0 2:20:36 AM Info 1400.0 2:20:36 AM Info 1600.0 2:20:37 AM Info 1800.0 2:20:37 AM Info 2000.0

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Didn't get you well, but maybe you need something like:

let counter = 0;
function repeatloop() {
  for (var i = 1; i <= 10; i++) {
    Utilities.sleep(10000);
    Logger.log(i);

    counter += rowcount();
    Logger.log(counter);
  }
  return rowcount();
}
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!