title: Retrieving the highest value without using the Math.max() function
body: <p>I am working on this problem and it seems to be getting the best of me.
  My code is to execute a function that returns the highest value without using the <code>Math.max()</code> function. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var arr = [42,13,34,8, -9, 3];
  
  function max(array, selector) {
  
    var val = array[0];   
  
    for (var i = 1; i &lt; array.length; i++) {
      if (selector == "Max") {
        if (array[i] &gt; val) {
          val = array[i];
        }
      }
  
    }
    return val;
  }
  
  console.log(max([42,34,8,13,-9]))</code></pre>
  </div>
  </div>
  </p>