Question Does anyone know of a way to round a float to the nearest 0.05 in JavaScript?
Example
BEFORE | AFTER
My solution and test:
let round = function(number, precision = 2, rounding = 0.05) { let multiply = 1 / rounding; return parseFloat((Math.round(number * multiply) / multiply)).toFixed(precision); };
https://jsfiddle.net/maciejSzewczyk/7r1tvhdk/40/