Euler Project, Problem 10: Summation of Primes

The sum of primes below 10 is 2 + 3 + 5 + 7 = 17.

Find the sum of all the primes below two million.

Here's the code I used to get the answer (originally at least; now I'm using someone else's Sieve of Eratosthenes code from StackOverflow!):


/*
  Find the summation of primes (Euler Problem 10)
  This solution takes about 30sec to run.  I don't really
  understand the Sieve of Eratosthenes so I could only copy one of the
  solutions on Stack Overflow...  This solution works and it was mine.
*/

$(document).ready( function() {

    function isPrime(n) {
      if (n === 1) { return false;}
      if (n === 2) { return true; }
      var sqrt_n = Math.round(Math.floor(Math.sqrt(n)));
      for (var i=2; i<=sqrt_n + 1; n++) {
        if (n % i === 0) { return false; }
	return true;
      }
    }

    var sum = 2;
    var limit = 2e+6;

    for (var i=3; i<=limit; i+=2) {
      if (isPrime(i)===true) { sum+=i; }
    }

    console.log(sum);

    $("#output").text("Sum is " + sum );

});