Sum All Primes, works in sublime but not in FCC

Made this for sum all primes challenge. The code works in Sublime but not on FCC. Any thoughts?
in sublime it returns 73156 (the right answer)
in FCC it returns 64615

Code so far

function sumPrimes(num) { 
	// start with a var to hold the total and set to zero
	var sum = 0;

	// run a loop from 2 to num inclusive
	for(let i = 2; i <= num; i++) {

		// set isPrime to true and try to prove false on next loop
		let isPrime = true;
		// checks if current i value is prime using a loop
		// if i is not prime sets isPrime to false
		for(let j = 2; j < i; j++) {
			if(i % j === 0) {
				isPrime = false;

		// if isPrime is true add i to the sum
		if(isPrime) {
			sum += i;

	// return the total
	return sum;



To protect you from accidentally crashing your browser with an infinite loop or infinite recursion, FCC will stop running your code if it is taking too long. Unfortunately, it is possible for a less efficient solution to be mistaken for an infinite loop.

1 Like

Good to know. Thanks for your help, and I’ll try and clean it up a bit.

1 Like

Happy coding!