In this program, You will learn how to find the sum of prime numbers between 1 to n in JavaScript.

```
while(Condition){
//Statement
Increment/Decrement
}
```

## Example: How to find the sum of prime numbers between 1 to n in JavaScript

```
let n = parseInt(prompt("Enter a number:"));
let s = 0;
for (j = 2; j <= n; j++) {
let p = 1;
let i = 2;
while (i < j) {
if (parseInt(j % i) == 0) {
p = 0;
break;
}
i++;
}
if (p == 1) {
console.log("Number is prime:" + j);
s = s + j;
}
}
console.log("Sum of all prime numbers:", s)
```

#### Output:

```
Enter a number:> 10
Number is prime:2
Number is prime:3
Number is prime:5
Number is prime:7
Sum of all prime numbers: 17
```