6 lines
183 B
Plaintext
6 lines
183 B
Plaintext
|
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;
|
||
|
}
|