How can I iterate over an element in an array but not move from the index until a condition is fulfill?

Hi fam happy Valentine’s.
I’m not looking for a code solution but some insights about how could I go about iterating over an array let’s call it array = [1, 1, 1], and not moving to the next element in the array until a condition is fulfilled. For example I want to start at index 0 and only go to the next index (1) after the value of such index is (modified/changed) to be greater than the value of the index before it. At 0 index we have the value 1, I want before moving to index 1 to change the value of index 1 to be greater then the value of index 0. Something like this if we have array = [1, 1, 1] I want to iterate over the array, start at 0 index. Compare if the value of 0 index is greater or equal than the value of index 1 (the next index) If so than add 1 to the value of index 1 until that value is greater than the value of index 0. First iteration we get array = [1, 2, 1].
Next iteration we get array = [1, 2, 3].

At this point I have tried to iterate over the array with a for loop grab each element, compare and add 1 to the element but when I get to the last element it does not add anything since I am at the end of the array and there is no item to loop over. I get array = [1, 2, 2] Please help fam. This is what I have so far.

     // array 
     const array = [1, 1, 1]
    
    // iterating over array
    for (let i = 0; i < array.length; i++) {
        // compare
        if (array[i] >= array[i + 1]) {
            // increase next number by 1
            array[i + 1] += 1
        }
    }