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

386
Vistas
¿Por qué agregar una declaración else ralentiza tanto mi código?

Siento que tal vez haya una respuesta obvia. Cuando estoy ejecutando este código:

 function searchQuery() { var compiledParticipantsSheet = spreadSheet.getSheetByName('Participants'); var participantsSheetLr = compiledParticipantsSheet.getLastRow(); var participantsSheetLc = compiledParticipantsSheet.getLastColumn(); var querySheet = spreadSheet.getSheetByName('Query'); var querySheetLr = querySheet.getLastRow(); var querySheetLc = querySheet.getLastColumn(); var data = querySheet.getRange(3, 1, querySheetLr, querySheetLc).getValues(); for (j = 2; j <= participantsSheetLr; ++j) { var val = compiledParticipantsSheet.getRange(j, 2, 1, 1).getValue(); console.log('Searching Query sheet for row ' + j + ' -- ' + val) for (i = 0; i < data.length; ++i) { if (data[i][4] == val) { var foundData = (data[i][20]); console.log('------ Found email in query row ' + (i + 3) + ' = ' + foundData); compiledParticipantsSheet.getRange(j, 11, 1, 1).setValue(foundData); }else{ compiledParticipantsSheet.getRange(j, 11, 1, 1).setValue('Participant not found'); } } } }

Funciona terriblemente lento, pero si elimino la declaración one else al final, ¡funciona súper rápido! ¿Es eso razonable? ¿Me estoy perdiendo de algo? ¡Gracias!

about 4 years ago · Santiago Gelvez
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