title: Javascript filter function not returning array
body: <p>function to return array of largest elements from each sub array</p>
  
  <hr>
  
  <pre><code>function largestOfFour(arr) {
        var max = 0;
        var newarr = [];
        newarr = arr.filter(function(elem) {
            max= 0;
            for(var i=0;i&lt;elem.length;i++) {
              if(max&lt;elem[i]) {
                max = elem[i];
              }
            }  
            return max;
          });
        return newarr;
      }
  
      largestOfFour([[4, 5000, 1, 3], [13, 27, 18, 26], [3, 35, 37, 39], [1000, 1001, 857, 1]]);
  </code></pre>