Skip to content

Instantly share code, notes, and snippets.

@tsh-code
Created October 2, 2018 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsh-code/59057ff904e2dbd0770ffde9a1c8136e to your computer and use it in GitHub Desktop.
Save tsh-code/59057ff904e2dbd0770ffde9a1c8136e to your computer and use it in GitHub Desktop.
function median(values) {
var values = values.sort( function(a,b) {return a - b;} );
var half = Math.floor(values.length/2);
if(values.length % 2)
return values[half];
else
return (values[half-1] + values[half]) / 2.0;
}
function getLast(values) {
return values.pop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment