JavaScript program which will take n input numbers and sum up
Problem Definition
Make a JavaScript program which will take n input numbers and sum up print the result all of input numbers when press 0 using do-while loop.
Code
<script>
var total=0;
var a=[];
do{
var n=parseInt(prompt("Enter a value:"));
a.push(n);
if(n==0)break;
total+=n;
}while(true);
document.write("Sum of "+a+" numbers is "+total);
</script>
Comments 0