Guest User

Untitled

a guest
Feb 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.18 KB | None | 0 0
  1. //snaps to a number by granularity
  2. module.exports = function(num, granularity = 1){
  3. if(granularity === 0){
  4. return num;
  5. }
  6. return Math.round(num/granularity)*granularity;
  7. }
Add Comment
Please, Sign In to add comment