This is for my GCSE Computer Science. Here's the code:
<html>
<p id="demo"></p>
<script>
var middaytemp = []; midnighttemp = [];
for (count = 0; count <= 29; count++) {
middaytemp[count] = prompt("What was the temperature at midday");
midnighttemp[count] = prompt("what was the temperature at midnight?");
document.getElementById("demo").innerHTML += middaytemp[count] + "° Celcius<br>";
document.getElementById("demo").innerHTML += midnighttemp[count] + "° Celcius<br>";
}
</script>
</html>
As you can see it asks these two questions 29 times each. I've got them in an array but I need to find the average of the array. so when the temperatures are put in at the end of the code it shows the average for the night and average for the day.
Celsius, notCelciusforloop with something likemiddaytotalandmidnighttotal. Then after the loop you calc the average, no aditional loops or functions are needed.