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

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

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 Relatório

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 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