I need something like this, so I wrote a function. I used the function for decimal rounding here , and since I also use it to round integers, I also set it as the answer. In this case, just enter the number you want to round, and then 10, the number you want to round to.
function roundToNearest(numToRound, numToRoundTo) { return Math.round(numToRound / numToRoundTo) * numToRoundTo; }
cjbarth Jan 09 '15 at 13:31 on 2015-01-09 13:31
source share