title: Javascript vs C++, same code, different result, why is that?
body: <p>I'm doing a code challenge and I found some strange stuff going on with my code, so I ran it with C++</p>
  
  <pre><code>function sumPrimes (num)
  {
      var sum=0;
      for(var i=2; i&lt;num; i++)
      {
          if(primeNumber(i)===true)
              sum+=i;
      }
      return sum;
  }
  
  
  function primeNumber (i)
  {
      if(i==2 || i==3 || i==5 || i==7)
          return true;
      if(i%2!=0 &amp;&amp; i%3!=0 &amp;&amp; i%5!=0 &amp;&amp; i%7!=0)
          return true;
  }
  
  sumPrimes(977);
  </code></pre>
  
  <p>which gives me result of 107812, but when I do the same with C++</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  bool primeNumber(int);
  int sumPrimes(int);
  int main()
  {
      int n;
      cout &lt;&lt; "n: ";
      cin &gt;&gt; n;
      cout &lt;&lt; "Sum : " &lt;&lt; sumPrimes(n) &lt;&lt; endl;
      system("PAUSE&gt;=0");
  }
  int sumPrimes(int n)
  {
      int sum = 0;
      for (int i = 2; i &lt; n; i++)
      {
          if (primeNumber(i) == true)
              sum += i;
      }
      return sum;
  }
  bool primeNumber(int i)
  {
      if (i == 2 || i == 3 || i == 5 || i == 7)
          return true;
      if (i % 2 != 0 &amp;&amp; i % 3 != 0 &amp;&amp; i % 5 != 0 &amp;&amp; i % 7 != 0)
          return true;
  }
  </code></pre>
  
  <p>the result is 108583.</p>
  
  <p>Can anyone explain what's going on?</p>