0

I have this code:

    self.tests.forEach((test: ITestRow) => {
        test.current = false;
        if (test.adminTestId == adminTestId &&
            (userTestId == 0 || test.userTestId == userTestId) &&
            (sequence == 0 || test.sequence == sequence)) {
            self.test = test;
            test.current = true;
            test.testId = testId;
            test.userTestId = userTestId;
        }
    });

I am not sure why but there are some cases where it sets more than one or the objects in the tests array to have current = true. I keep seeing this but I am having a hard time duplicating it.

Would appreciate any advice on if I am doing something wrong with the logic. Also is there a way that I can break out of the .forEach as there will be at most only one row that should be set to true at one time.

Alan2
  • 23,493
  • 79
  • 256
  • 450

0 Answers0