variables which affect each other resulted in nested loop problems

Change for (x in cm){ to for (let x in cm){ so you aren’t accidentally using a global x which will get overwritten between multiple calls to this function (because of the asynchronous operations here).

Even better, change it to for (let x of cm) { and then change cm[x] to just x inside the loop.

FYI, if you run your code in strict mode, then this type of error is flagged for you automatically.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top