I have come across this problem and embarassed to say I have never devised a good solution that has left me feeling satisfied -
I want to count to a number and then once the number is reached start counting up from 0 again.
so in JavaScript, we might have
var incr = 0;
if (incr === 50) {
incr = 0;
}
incr++;
is there a more elegant way to do that, or is this pretty much the only way to do it? I keep thinking there is a way to do it with Math.max or Math.min, but never have figured it out.