title: How to make an average of an array in JavaScript
body: <p>This is for my GCSE Computer Science. Here's the code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;p id="demo"&gt;&lt;/p&gt;
  &lt;script&gt;
  var middaytemp = []; midnighttemp = [];
  for (count = 0; count &lt;= 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] + "&amp;deg; Celcius&lt;br&gt;";
  document.getElementById("demo").innerHTML += midnighttemp[count] + "&amp;deg; Celcius&lt;br&gt;";
  }
  &lt;/script&gt;
  &lt;/html&gt; 
  </code></pre>
  
  <p>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.</p>