[Vuejs]-Potential infinite loop: exceeded 10001 iterations

3👍

The bug appears to be in makeObject(), shown below:

const makeObject = (jobs, img, org) => {
  let mjobs = [];
  for (let i = 0; i < jobs.length; i++) {
    jobs.push({        // FIXME: Pushing into `jobs` which is being iterated
      title: jobs[i],
      img: "https://merojob.com" + img[i],
      org: org[i]
    });
  }
  return mjobs;
}

The for-loop iterates jobs, while pushing new objects into it. The termination condition checks that i is less than jobs.length, which is being incremented on each iteration, so it never exits the loop.

I think you meant to push into mjobs inside the for-loop.

Leave a comment