6 lines
183 B
Plaintext
Raw Normal View History

2022-08-14 21:06:41 -07:00
function linear_approach(val, goal, amount) {
if abs(val-goal) < amount val = goal;
if val < goal return val+amount;
if val > goal return val-amount;
if val == goal return goal;
}