Skip to content

Instantly share code, notes, and snippets.

@dustinpoissant
Created January 24, 2017 16:47
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 dustinpoissant/17cfe5401fe5644a371fe21502bbe52b to your computer and use it in GitHub Desktop.
Save dustinpoissant/17cfe5401fe5644a371fe21502bbe52b to your computer and use it in GitHub Desktop.
Round a number to the nearest "X"
function roundTo(number, to){
return (Math.round(number * (1/to)) / (1/to));
};
function roundTo(a,b){return Math.round(a*(1/b))/(1/b)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment