static/js/util.js
/**
 * Calculate both min and max of a numeric array.
 * Better performance comparing to Math.min + Math.max.
 * @function arrMinMax
 * @param {number[]} arr - input array
 * @returns {[number, number]} min and max
 */
Calculate both min and max of a numeric array.
Calculate both min and max of a numeric array .
function arrMinMax(arr) {
  var val = arr[0];
  var min = val;
  var max = val;
  for (var i = 1; i < arr.length; i++) {
    var val = arr[i];
    min = (val < min) ? val : min;
    max = (val > max) ? val : max;
  }
  return [min, max];
}
function arrMinMax ( arr ) { var val = arr [ 0 ] ; var min = val ; var max = val ; for ( var i = 1 ; i < arr . length ; i ++ ) { var val = arr [ i ] ; min = ( val < min ) ? val : min ; max = ( val > max ) ? val : max ; } return [ min , max ] ; }
Calculate both min and max of a numeric array.
Calculate both min and max of a numeric array .