The below function will help us to find the sum of N Natural numbers using do..while loop
function SumofNNaturalNumbers() {
var N=10;
var sum = 0;
var i=1;
do{
sum+=i;
i++; }while(i<=N);
alert("Sum Of N Natural Numbers : " + sum);
}
We are looping through the numbers till it reaches the maximum end and summing the individual numbers. Finally, printing the same using the alert.