Rounds a number to a multiple.
Round to multiple of 5
5
const roundTo5 = roundToMultiple(5);console.log(roundTo5(4)); // 5console.log(roundTo5(-3)); // -5
Round to -3, 2, 7, ...
-3
2
7
const roundTo5Plus2 = roundToMultiple(5, 2);console.log(roundTo5Plus2(0)); // 2console.log(roundTo5Plus2(8)); // 7console.log(roundTo5Plus2(-5)); // -3
the rounded number
the multiple to round to
optional shift to apply
Generated using TypeDoc
Rounds a number to a multiple.
Example
Round to multiple of
5Example
Round to
-3,2,7, ...Returns
the rounded number