just-median

return the median value of an array of numbers

Usage no npm install needed!

<script type="module">
  import justMedian from 'https://cdn.skypack.dev/just-median';
</script>

README

just-median

Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.

🍦 Try it

npm install just-median
yarn add just-median

Return the median value of an array of numbers

import median from 'just-median';

median([1, 2, 3, 4, 5]); // 3
median([3, -1, 2]); // 2
median([9, 14, 14, 200, 15]); // 14
median(1, 2, 4, 3); // 2.5
median(['3', 2, 1]); // throws
median(); // throws