function round(number, increment, offset) { return Math.ceil((number - offset) / increment ) * increment + offset; } round(51, 20, 10) // 70 round(70, 20, 10) // 70 round(99, 20, 10) // 110 round(100, 20, 10) // 110