Tell us what’s happening:
Describe your issue in detail here.
i feel my code is not efficient code because it needs alot of steps to excute to come up with the solution so tell me how can i improve it ??
**Your code so far**
function sumPrimes(num) {
let j=2;
let arr = [];
let sum =0;
while(j <= num){
let isPrime = true;
for(let i =2;i<num;i++){
if((j/i)%1 == 0 && i !=j){
isPrime = false;
break;
}
}
if (isPrime == true){
arr.push(j);
}
j++
}
for(let i=0;i<arr.length;i++){
sum += arr[i];
}
return sum;
}
sumPrimes(977);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36
Challenge: Intermediate Algorithm Scripting - Sum All Primes
Link to the challenge: