I need help with For Loop With Delay when used with wave enemies

Since you are spawning them with a delay and checking array length after each kill, it could be that it removes from the array leaving it = 0 and it moves to next wave while still spawning the remaining from prev wave?