Geekality
Blog
About
Search
Home
Blog
Javascript: Round number to nearest multiple
Javascript: Round number to nearest multiple
Published:
10 October 2018
software-development
javascript
math
const
roundToNearest
= (
i, n
) => (i % n > n /
2
? i + n - (i % n) : i - (i % n))
Source
https://gist.github.com/aslakhellesoy/1134482#gistcomment-44491