title: Javascript For Loop Causes Unexpected Behaviour
body: <p>Code Sample A</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var isPrime = function (num) {
      //for(i = 1; i &lt;= num; i++) {}
      if(num === 2){
        return true;
      }
      return false;
  };
  
  
  var sumPrimesUpTo = function (num) {
      
      for(i = 1; i &lt;= num; i++) {
         console.log(isPrime(i));
      }
      
  };
  
  sumPrimesUpTo(5);</code></pre>
  </div>
  </div>
  </p>
  
  <p>So we have a function that supposedly checks for a prime number and a second function that sums prime numbers up to a provided number. When you run this it outputs.</p>
  
  <pre><code>false
  true
  false
  false
  false
  </code></pre>
  
  <p>Now we have the same code sample but with the for loop in isPrime uncommented.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var isPrime = function (num) {
      for(i = 1; i &lt;= num; i++) {}
      if(num === 2){
        return true;
      }
      return false;
  };
  
  
  var sumPrimesUpTo = function (num) {
  
      for(i = 1; i &lt;= num; i++) {
         console.log(isPrime(i));
      }
     
  };
  
  sumPrimesUpTo(5);</code></pre>
  </div>
  </div>
  </p>
  
  <p>This outputs</p>
  
  <pre><code>false
  false
  false
  </code></pre>
  
  <p>I don't seem to get why the for loop changes the output?</p>