Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

269
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda