title: What is missing to get correct output. I am trying to print Maximum and minimum in the array
body: <p>When I run this code in browser console or any JavaScript environment, I get max and min as 1,1. Could someone help me to find the error.</p>
  <pre><code>var arr = [1,4,6,3];
  function maxAndMin(arr) {
  var max = arr[0];
  var min = arr[0];
  for(var i=0; i &lt; arr.lenght; i++) {
    if(arr[i] &gt; max) {
    max = arr[i];
  }
    if(arr[i] &lt; min) {
    min = arr[i];
  }}
  console.log(&quot;Max:&quot;,max,&quot;Min:&quot;,min);
  }  
  
   maxAndMin(arr);
  </code></pre>