Condition Inside While (won't drop the while cond)

If Y is >= a certain integer (10), then I want the code to go to next case statement. Problem is, that the integer is inside a while statement. Even though Y can and will go past 10, it just stays in the while loop inside of right away dropping and moving on to next case. Why?..how to get around this?

p.s. elapsedMillis timeElapsed is a special library to start millis back at 0 every time you call it.

 case S_normalTwo: {
        elapsedMillis timeElapsed;
        elapsedSnap = timeElapsed;
        Serial.println("S_normalTwo");
        while ((timeElapsed) < (elapsedSnap + 5000)) {
          int y;
          thisFunction(y);
          Serial.println (timeElapsed);

          if (y >= 10) {
            Serial.println("we made it here at least!");
            updateTimeTwo = timeElapsed;
            state = S_reverseTwo;
          }

          if ((timeElapsed) >= (elapsedSnap + 5000)) {
            state = S_waitForSwitchPinHigh;
          }

        }

        if ((timeElapsed) >= (elapsedSnap + 5000)) {
          state = S_waitForSwitchPinHigh;
        }
while ((timeElapsed) < (elapsedSnap + 5000)) {
  1. That’s not rollover safe timing. Should always use subtraction.

  2. Since nothing inside the while loop ever changes timeElapsed or elapsedSnap, once you’re in there you’re stuck forever. If that statement is true to get you into the while loop, and nothing in the while loop ever changes either variable, then it’s still going to be true.

Why? Because that's the whole point of while(), it keeps looping until the condition is satisfied. Luckily we have this useful thing called break() break that will exit the while loop. See:
https://www.arduino.cc/en/Reference/Break

Luckily we have this useful thing called break(), that will exit the while loop

Except that break isn't a function... 8)