title: Difference between the smallest and biggest number in an array
body: <p>I'm stuck with the following assignment.</p>
  
  <p><em>Code this function to take an array and return the difference between the smallest and the biggest number.</em></p>
  
  <p>I've tried the following but keep getting an error. What am I doing wrong?</p>
  
  <pre><code>function differenceMinMax(array) {
  
       var arrayMin = array[0];
       var arrayMax = array [0];
  
       for  (var i=0; i &lt;= array.length; i++) {
  
       if (array[i] &lt; arrayMin) {
         arrayMin = array[i];
       } 
       if (array[i] &gt; arrayMax) {
         arrayMax = array[i];
       }
      }
  
      return arrayMax - arrayMin;
  
      }
  </code></pre>