Home  • Programming • JavaScript

JavaScript program which will take n input numbers and sum up

Code Solutions [4384] 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


Copyright © 2024. Powered by Intellect Software Ltd