Skip to content

Instantly share code, notes, and snippets.

@VFDan
Created March 24, 2020 17:19
Show Gist options
  • Save VFDan/db793c15620f64ab13cbea1c0b707d6f to your computer and use it in GitHub Desktop.
Save VFDan/db793c15620f64ab13cbea1c0b707d6f to your computer and use it in GitHub Desktop.
Median and mean
Math.median = (...nums) => {
nums.sort()
len = nums.length/2
if (len%1) return nums[Math.floor(len)]
return mean(nums[len],nums[len-1])
}
Math.mode = (...nums) => nums.reduce((a,b)=>a+b, 0)/nums.length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment