Loops a value within a specified range. If the value exceeds max, it wraps back to min. If it's below min, it wraps around to max.
max
min
The value to wrap around the range.
The minimum value of the range.
The maximum value of the range.
loop(0, 0, 3); // => 0loop(1, 0, 3); // => 1loop(2, 0, 3); // => 2loop(3, 0, 3); // => 0 (wraps back to the start)loop(-1, 0, 3); // => 2 (wraps from below to the end)loop(-2, 0, 3); // => 1loop(-3, 0, 3); // => 0 Copy
loop(0, 0, 3); // => 0loop(1, 0, 3); // => 1loop(2, 0, 3); // => 2loop(3, 0, 3); // => 0 (wraps back to the start)loop(-1, 0, 3); // => 2 (wraps from below to the end)loop(-2, 0, 3); // => 1loop(-3, 0, 3); // => 0
Loops a value within a specified range. If the value exceeds
max
, it wraps back tomin
. If it's belowmin
, it wraps around tomax
.