 <p>You have a spurious semicolon between the <code>for</code> loop and what you think is the body. Eliminate that and it should work as expected.</p> <pre><code>for(x = 0; x &lt; 3 ; x++); { ^ | eliminate this </code></pre> <p>What's happening now is that the <code>for</code> loop is looping three times and each time it is executing the empty statement formed by the semicolon. Then the block statement that you want executed three times is being executed once.</p>