Created
January 24, 2017 16:47
-
-
Save dustinpoissant/17cfe5401fe5644a371fe21502bbe52b to your computer and use it in GitHub Desktop.
Round a number to the nearest "X"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function roundTo(number, to){ | |
return (Math.round(number * (1/to)) / (1/to)); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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