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

231
Vistas
TS: Boolean for for loop equals true on line before, still won't run

This function to label inside of a range using a for loop will not run the logic inside the for loop at all. Previously, I was defining the arguments for the for loop more dynamically, using indexing, and it was consuming all of my memory running a multimillion length loop. Completely unsure how this loop is not running.

      selectMonth(newMonth: number) {
        console.log(newMonth);
        const NMH: number[] = [ 744, 1416, 2160, 2800, 3624, 4344, 5088, 5832, 6552, 7296, 8016];
        const WH: number = 168;
        let labelValue: Label[] = ['Sunday'];
        // let i = NMH[newMonth];
        let WC = 0;
        let loopSize = NMH[newMonth + 1] - NMH[newMonth];
        console.log(" loopSize" , loopSize);
        let i = 0;
        console.log("i right before" , i, i < loopSize)
        for(i; i++; i < loopSize) {
          console.log("inside loop" , i)
        }
        console.log(labelValue);
  }

console print out of this function

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Just swap conditional statement i < loopSize and step i++.

      selectMonth(newMonth: number) {
        console.log(newMonth);
        const NMH: number[] = [ 744, 1416, 2160, 2800, 3624, 4344, 5088, 5832, 6552, 7296, 8016];
        const WH: number = 168;
        let labelValue: Label[] = ['Sunday'];
        // let i = NMH[newMonth];
        let WC = 0;
        let loopSize = NMH[newMonth + 1] - NMH[newMonth];
        console.log(" loopSize" , loopSize);
        let i = 0;
        console.log("i right before" , i, i < loopSize)
        for(i; i < loopSize;i++) {
          console.log("inside loop" , i)
        }
        console.log(labelValue);
  }
about 4 years ago · Juan Pablo Isaza Denunciar

0

I just realized that the arguments are flipped around. For loop should be initiated with:

for(i; i++; i < loopSize) {

There are some dumb questions haha

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