title: Max/Min/Avg returning array in that order
body: <p>Can anyone tell me what I'm doing wrong? I am printing the array just not in the right order. How do i call it differently? This is javascript by the way.</p>
  
  <p>Given an array x (e.g. [1,5, 10, -2]), create an algorithm (sets of instructions) that returns an array with the max, min, and average values ([max, min, avg]. ex [0,2,4] should return [4,0,2]).</p>
  
  <p>My code: </p>
  
  <pre><code>function maxMinAvg(arr) {
      var newarr= [];
      var max = arr[0];
      var min = arr[0];
      sum = sum + arr[0];
      var avg = sum/arr.length;
      for (var i = 1; i &lt; arr.length; i++) {
          if (arr[i] &gt; max) {
              max = arr[i];
          }
          if (arr[i] &lt; min) {
              min = arr[i];
          }
          sum = sum + arr[i];
      }
      newarr.push([max[i],min[i],avg[i]]);
  }
  
  return newarr;
  </code></pre>