javascript - Round to nearest multiple with offset in JS -
i have number want round nearest multiple of x with offset. example, how round number nearest number 5 more multiple of 12 (ie 5, 17, 29...)?
in case it'd this:
var input = 34; var offset = 5; var multiple = 12; var result = (math.round((input - offset) / multiple) * multiple) + offset;
this should find nearest number 34 5 more multiple of 12 (29)
Comments
Post a Comment