I am new into Javascript btw thus I really hope someone can help me point out my mistake. I have done all the things that the question asked except for the calculation for total and average part. I got it wrong and I dont know what went wrong. Example marks I have keyed in were 1,2,3,4. Supposed to be the total and average should be 10 and 2.5 but it displayed 1234 and 308.5. Here`s what I have tried :
```
<!DOCTYPE html>
<html>
<head>
<title>MARK</title>
</head>
<body>
<script src="mark.js"></script>
<form>
Mark : <input type="text" id="Mark1" /><br>
Mark : <input type="text" id="Mark2" /><br>
Mark : <input type="text" id="Mark3" /><br>
Mark : <input type="text" id="Mark4" /><br>
<br>
<input type="button" onClick="findTotal()" Value="Find Total" />
<input type="button" onClick="findAverage()" Value="Find Average" />
</form>
<br>
Result : <br>
<span id = "result"></span>
</body>
</html>
```
<pre><code>
function findTotal()
{
var num1 = document.getElementById("Mark1").value;
var num2 = document.getElementById("Mark2").value;
var num3 = document.getElementById("Mark3").value;
var num4 = document.getElementById("Mark4").value;
document.getElementById("result").innerHTML = num1 + num2 + num3 + num4;
}
function findAverage()
{
var num1 = document.getElementById("Mark1").value;
var num2 = document.getElementById("Mark2").value;
var num3 = document.getElementById("Mark3").value;
var num4 = document.getElementById("Mark4").value;
document.getElementById("result").innerHTML = (num1 + num2 + num3 + num4) / 4;
}
</code></pre>