I have two numbers wich can change, like x1 and x2. Then I also have an other number what is random but always between x1 and x2, like z. What I want to do is change z to the nearest x.
Sooo if I give you guys an example:
Input:
x1 = 12.24
x2 = 346.92
z = 274.45
Output:
z = 346.92
z is now 346.92 because that is the nearest number for z. This is what I am trying to do in Javascript. I thought there was no command for and you have to do it with just some math. I really have no idea how to do that... But there are you!
Thnx for all your help!