title: Maximum and minimum value in an Array
body: <p>I wrote a Ruby code to get max and min values from an array. The code prints the max value (8) correct but it's not printing the minimum value (2). Please let me know what went wrong in my code.</p>
  
  <pre><code>class MaxMinArray
    def MaxMinMethod()
      array = [4,2,8,3,5]
      maxNo = array[0]
      minNo = array[0]
      arrayLength = array.length
      for i in 1..arrayLength
        if array[i].to_i &gt; maxNo
          maxNo = array[i]
        end
        if array[i].to_i &lt; minNo
          minNo = array[i]
        end
      end
      puts "Maximum no. in the given array: " + maxNo.to_s
      puts "Minimum no. in the given array: " + minNo.to_s
    end
  end
  
  MaxiMinArrayObj = MaxMinArray.new
  MaxiMinArrayObj.MaxMinMethod()
  </code></pre>