@princedev/calculate
Version:
Fast, lightweight, and extinsible mathematical and statistical functions.
22 lines (21 loc) • 489 B
TypeScript
/**
* @name median
* @summary Returns the median.
*
* @description Arranges the numbers in order and gets the number halfway the list.
*
* @example
* // Normal usage
* let result = median(21,4,8,6);
* // => 7
*
* // Using an array
* let result = median(...[21,4,8,6]);
* // => 7
*
* @param {Array<number>} args given numbers.
* @returns {number} the resulting median.
*
* @function pure
*/
export default function median(...args: number[]): number;