title: Simple average function in Javascript
body: <p>How could I calculate average using a function:</p>
  
  <pre><code>function calculate(array) {
      var sum = 0;
      for (var i = 0; i &lt; array.length; i++) {
          sum = sum + array[i];
      }
      return sum;
  }
  document.write(calculate([24, 88, 12, 4]));
  </code></pre>
  
  <p>(I don't understand how to get the arguments length)</p>