how to get user input in javascript and get sum

Solutions on MaxInterview for how to get user input in javascript and get sum by the best coders in the world

showing results for - "how to get user input in javascript and get sum"
Jona
19 Sep 2019
1	<script>
2		
3		var tot = 0;
4		var mark = 0;
5		var avg = 0;
6		
7		for(i=1; i<=5; i++)
8		{
9			Mark = prompt("Enter "+i+" mark below","");
10			
11			tot = Number(tot)+Number(Mark);
12		}
13		
14		avg = tot/5;
15		
16		document.write("Sum is: "+tot);
17		document.write("<br>Average is: "+avg);
18		
19	</script>