Sum All Primes Exercise

Tell us what’s happening:

Hello guys, I m stuck here in the SumPrime exercise. May I ask for your help here?
Thanks

Here is my code:

function sumprimes(num) {
  let alpha = []

  for(let i = 0; i < 10; ++i) {
    if(i==2 || i % 2 !== 0 {
      alpha.push(i)
    }
  }

  alpha.includes(1) ? alpha.splice(alpha.indexOf(1),1) : console.log('');

  let primes = [];

  for(let j = 11; j < num; ++j) {
    let counter = 0;

    for(let a = 0; a < alpha.length; ++a) {
      if(j % alpha[a] !== 0) {
        counter +=1

        if(counter === alpha.length && primes.includes(j) == false) {
          primes.push(j)
          counter = 0
        }
      }
    }
  }

  let process = alpha.concat(primes);
  // console.log(process);

  let done = process.filter(e=> {
    return !Number.isInteger(Math.sqrt(e))
  });

  return done.reduce((a, b) =>{ return a + b });
}

sumprimes(100);

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums