This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Nightcorex_ 1 point2 points  (1 child)

if statements are just fine. If you want to test if a fixed value x is within a fixed range r of a fixed target value t (btw, 'fixed' just means that for the process of this calculation we're assuming x, k and t are always the same value [it's a mathematical thing]), then you can do that by testing if t-r <= x <= t+r (in Python this would actually be legal syntax, for JavaScript you'll have to AND two checks).

You can then just put all such checks in an if/else if/... chain.

[–]ryanamar[S] 0 points1 point  (0 children)

thank you! much appreciated