Sum All Primes bug

Tell us what’s happening:

hello guys my code is working just fine in but not here for the last step

Your code so far

function sumPrimes(num) {
  let arr = []
  let pri = []
  for (let i = 2 ; i <= num ; i++){
 for (let i = 0 ; i<arr.length ;i++){
   for (let j = 0 ; j<arr.length ;j++){
     if (arr[i]%arr[j] === 0 && arr[i] !== arr[j]){
     delete arr[i]
  return arr.reduce(function (a,b){return a+b});


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0.

Link to the challenge:

It’s not a bug: the execution time is heavily constrained on FCC, and the huge amount of work your code is doing makes your solution very slow. You need to try to rethink/optimise the algorithm you’ve chosen to use.

For example, if you try to run it here (an app that allows you to walk though every operation a function goes through), the app will refuse to run your function because of the number of operations you’re doing:

1 Like