<div dir="ltr"><div>I have several codes like the following:</div><div><br></div><div>for var i = 0; i &lt; myarr.count; i += n { // the step is NOT 1</div><div>   // many codes</div><div>}</div><div><br></div><div>I knew I could use the while loop, but it seems very ugly.</div><div>var i = 0</div><div>while i &lt; marr.count {</div><div>    // some codes</div><div><br></div><div>    i += n   // Sometimes it is easy to be missed</div><div>}</div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></p><div>If no C-style for loop,  what&#39;s the best replacement for it ?</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">          </p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></p></div></div>