Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

277
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda