Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!