Get lowest value on an array - Node.js Array

Node.js examples for Array:Search

Description

Get lowest value on an array

Demo Code

/**/*from   w  w  w . j  a v  a2  s  .c o m*/
 * Get lowest value on an array
 */
Array.prototype.lowest = function() {
  var lowest_value = this[0];
  for(var i=1; i<this.length; i++) {
    if(this[i] < lowest_value) {
      lowest_value = this[i];
    }
  }
  return lowest_value;
}

Related Tutorials