I've found a mistake on the Guide of Intermediate Algorithm Scripting: Sum All Primes

The problem that I found is in the advanced code solution. Inside the while loop. Instead check all dividers from 2 up to the square root of the given number “n” (as the theorem says), the code checks from n-1 until the square root n. And that has non sense, is less efficient (although seems works fine btw) and doesn’t match with the given code explanation in the guide.
PS: That part has also an indentation problem at the if conditional that makes the code less readable especially for a new learner like me.

Here is the original code: Guide Intermediate Algorithm Scripting: Sum All Primes

And here is my code proposal:

    // step 1	
    let arr = Array.from({length: num+1}, (v, k) => k).slice(2); 
    // step 2
    let onlyPrimes = arr.filter( (n) => { 
      let m = 2;
      while (m > 1 && m <= Math.sqrt(n)) { 
        if ((n % m) === 0) { 
          return false;
        return true;
    // step 3
    return onlyPrimes.reduce((a,b) => a+b); 

As you can see my code inside the filter method is different, has sense and match with the explanation given below.

So, How can I change the solution in the guide?

Many thanks.

Contributing to the Guide is incredibly easy. Look at the CONTRIBUTING document for more information.

Can you share with me the link for contributing to the guide of this challenge? I’ve found an archive in Github but the guide page is different.

If you go to the link above and read that, you’ll find another more detailed document for contributing to the Guide.

The only thing that I’ve found is this https://github.com/freeCodeCamp/freeCodeCamp/blob/master/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-primes.english.md

Are you trying to change the challenge or the Guide article?

The guide article, the challenge is fine.

The link you included above is the challenge, not the guide.

1 Like

Then, How can I modify the guide?

The Guide is in the guide directory. The lessons are in the curriculum directory.