title: What is logic behind Math.max method?
body: <p>I want to create a function max that will return max value number.</p>
  
  <p>I managed so far:</p>
  
  <pre><code>function max() {
      var arr = [];
      for (var i in arguments) {
          arr.push(arguments[i]);
      }
      arr.sort(function (a, b) {
          return b - a;
      });
      return arr[0];
  }
  var test = max(30, 20, 50, 40, 100, 150, 5, 230);
  var test2 = Math.max(30, 20, 50, 40, 100, 150, 5, 230);
  </code></pre>
  
  <p>Both returns 230;</p>
  
  <p>But I don't want to use in-built functionality i.e Math.max. Also no prototype. So how I can do this?</p>
  
  <p>Any guidance would be appreciated.</p>