How can I resolve this problem with "while" : <p>I want to make a timer using while, and when I lunch the code in Chrome, the Chrome don't load.</p>

<p>I am making this:</p>

<pre><code>var time = 0;

        while (time &lt; 5) {
            setTimeout(function(){
                tempo[0].innerHTML = time;
                time++;
            }, 1000);
        }
</code></pre>

<p>I expect when time it gets to 5, javascript will exit the loop and execute the next action</p>
