median - nodef/extra-math GitHub Wiki

Find the value separating the higher and lower halves of numbers.

Similar: mean, median, modes, variance, range.

function median(...xs)
// xs: a list of numbers
const xmath = require('extra-math');


xmath.median(1, 7);
// → 4

xmath.median(1, 7, 8);
// → 7

xmath.median(1, 7, 8, 10);
// → 7.5

References