Helpers

calculateMedian.mjs

@mr_ozio/scraper-utils · v2.5.0 · Generated April 21, 2026

Target Style

Target Style

1 exports

const

medianOf

Target Style
export const medianOf = (values) => {

Calculates the median with a shorter, more readable call shape.

Target style API. Preferred for new code.

Parameters

  • valuesnumber[]

Returns

number

Legacy Style

Legacy Style

1 exports

const

calculateMedian

Legacy Style
export const calculateMedian = (values) => medianOf(values)

Calculates the median value.

The input array is sorted in place before the median is picked.

Legacy API. Kept for older code and not the preferred choice for new code.

Parameters

  • valuesnumber[]

Returns

number

Example

const median = medianOf([1200, 1500, 1800])