robosats/frontend/src/utils/match.ts
KoalaSat 425225d23d
Add book depth chart (#219)
* Amount X Axis, Avatars and refactor

* Theme and performance improvements

* Remove duplicated tooltips

* Code Review

* Marker Theme color

* Missing end lines

Signed-off-by: KoalaSat <111684255+KoalaSat@users.noreply.github.com>
2022-08-30 13:12:15 -07:00

8 lines
231 B
TypeScript

export const median = (arr: number[]) => {
const mid = Math.floor(arr.length / 2),
nums = [...arr].sort((a, b) => a - b);
return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
};
export default median