簡體   English   中英

Javascript:如何在每次通過迭代時添加最后一個數字?

[英]Javascript: how to add the last number on each passing iteration?

再會,

如何將最后一行計數添加到每次傳遞中,假設 function repeatloop() 代碼低於傳遞 2000 進行 1 次傳遞,如何將 2000 添加到發生的每次傳遞中,所以如果傳遞是 10,則 == 到 20 000 在 10 結束時通過,請參閱下面的代碼:

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();
}

所以目前 output 正在這樣做:

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

沒有讓你好,但也許你需要類似的東西:

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();
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM