Use for instead of while

Proper `for` usage saves some bytes.
Oops! here should be `array.length` instead of `this.length`