<html> <head> <script> function sum10() { var count = 0 var sum= 0 while(count<10) { var n = +prompt("Enter number") if(n>0) { count = count + 1 sum = sum + n } } var avg=sum/10 var result = document.getElementById("result") result.innerHTML = "Total = " + sum +"avg ="+avg } </script> </head> <body> <input type="button" value="Go" onclick="sum10()"/> <div id="result"> sum=0, avg=0 </div> </body> </html>
Office no.- 401,Shekhar Central Building ,Palasiya, Pin-code:452001, Indore
contact@codebetter.in
+91 88230 75444, +91 99939 28766