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

215
Views
Recursive Function: Maximum call stack size exceeded

i call myFunc1 with counter val 2. myFunc1 calls myFunc2 and increases each time counter.

It should stop when counter val is 4.

Why does this not work?

I get error "Maximum call stack size exceeded"

myFunc1 = (counter) => {
    if(counter < 5) {
      myFunc2(counter);
  }
}

  myFunc2 = (counter) => {
    myFunc1(counter++);
}

myFunc1(2);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

counter++ returns the value of counter and then increments the variable. You should use counter + 1 or ++counter which increments, then returns the value.

see more info

myFunc1 = (counter) => {
    if(counter < 5) {
      myFunc2(counter);
    }
}

myFunc2 = (counter) => {
    myFunc1(counter + 1);
}

myFunc1(2);
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!