Different break conditions in a for loop

I've been googling around a bit as I would like to break a loop with two different conditions. Haven't found anything useful so I will try here. I'm not after a complete solution, just a general approach.

At the moment I loop through the array with something like

for (var i=0;i<length;i++) ... if (this || that)...break ...msg

but when the break is triggered I don't which condition it was that caused it. So I tried to do something like

for (var i=0;i<length;i++) ... if (this)...break ...msg1... else if (that) ... break...msg2

but that didn't feel right and I don't know if it's even possible to do it like that. I thought I could do the first condition loop in one function node and then deal with the other condition in a second node that loops the messages that go through the first one with out triggering a break, but I'm thinking there has to be a better way. Any suggestions?

Either test this or that again after the break, or set a flag in the loop

let flag = 0
for (var i=0;i<length;i++) {
  if (this) {
    flag = 1
    break
  }
  if (that) {
    flag = 2
    break
  }
  ...
}
// test flag here

Thanks @Colin. Do I treat flags just like variables?

It is a variable, you can call it whatever you like, I called it flag because I didn't know what it actually means in your system, you can call it something more meaningfull in your system.
On a side note you should generally use let rather than var as the scope of let is more constrained. If you wanted to test this and that after the break rather than use a variable then define i before the for loop then it will still have a valid value after the break.

Great, thanks.