lib/perf.js
function getMedian (args) {
  if (!args.length) return 0
  var numbers = args.slice(0).sort(function (a, b) { return a - b })
  var middle = Math.floor(numbers.length / 2)
  var isEven = numbers.length % 2 === 0
  var res = isEven ? (numbers[middle] + numbers[middle - 1]) / 2 : numbers[middle]
  return Number(res.toFixed(2))
}
function getMedian (args) {
  if (!args.length) return 0
  var numbers = args.slice(0).sort(function (a, b) { return a - b })
  var middle = Math.floor(numbers.length / 2)
  var isEven = numbers.length % 2 === 0
  var res = isEven ? (numbers[middle] + numbers[middle - 1]) / 2 : numbers[middle]
  return Number(res.toFixed(2))
}
function getMedian ( args ) { if ( ! args . length ) return 0 var numbers = args . slice ( 0 ) . sort ( function ( a , b ) { return a - b } ) var middle = Math . floor ( numbers . length / 2 ) var isEven = numbers . length % 2 === 0 var res = isEven ? ( numbers [ middle ] + numbers [ middle - 1 ] ) / 2 : numbers [ middle ] return Number ( res . toFixed ( 2 ) ) }
Get the median from an array of numbers.
Get the median from an array of numbers .