title: Why does the console return a first random number before the loops when I run this code?
body: <pre class="lang-js prettyprint-override"><code>for(let i = 0; i&lt; 3; i++){ 
    setTimeout(function (){
      console.log(i)
    }, 200);
  }
  </code></pre>
  <p>The above code first returns a random number each time I run it in the console before returning <code>0 1 2</code>.</p>
  <p>Why does it happen like that?</p>