Answers for "how to get user input in javascript and get sum"

0

how to get user input in javascript and get sum

<script>
		
		var tot = 0;
		var mark = 0;
		var avg = 0;
		
		for(i=1; i<=5; i++)
		{
			Mark = prompt("Enter "+i+" mark below","");
			
			tot = Number(tot)+Number(Mark);
		}
		
		avg = tot/5;
		
		document.write("Sum is: "+tot);
		document.write("<br>Average is: "+avg);
		
	</script>
Posted by: Guest on July-30-2021

Code answers related to "how to get user input in javascript and get sum"

Code answers related to "Javascript"

Browse Popular Code Answers by Language