title: Javascript - find max and min values using loop and array, -Infinity/Infinity
body: <p>Could someone explain to me how does this work. In find highest number method every number is larger than -Infinity. Why does it take the highest number? Same with lowest number finder, how does it selects lowest number, all of the numbers are smaller than Infinity. </p>
  
  <pre><code>//find highest number
  
  var Numbers = [1, 2, 101, 45, 55, 1443];
  var l = Numbers.length;
  var max = -Infinity;
  var i;
  for (i = 0; l &gt; i; i++) {
  
      if (Numbers[i] &gt; max) {
  
          max = Numbers[i];
  
      }
  
  }
  
  console.info(max);
  
  //find lowest number
  
  var Numbers = [1, 2, 101, 45, 55, 1443];
  var l = Numbers.length;
  var max = Infinity;
  var i;
  for (i = 0; l &gt; i; i++) {
  
      if (Numbers[i] &lt; max) {
  
          max = Numbers[i];
  
      }
  
  }
  
  console.info(max);
  </code></pre>