## How to write a function to exponentially increase a number to its max

I have a variable called `turnRadius` that comes from user input and can be between -1 and 1, 0 being default.

I then have to convert this number into its equivalent in a range of 275 and 0 and store in variable `spriteHorizontalPosition`.

The problem is, for reasons I cant expect the user to set `turnRadius` all the way to -1 or 1, so I want that when `turnRadius` reaches `0.65` or `-0.65`, to increase exponentially to its max/min so that user doesnt have to reach the full number with input.

I think I get the idea but I don’t know how to write the function, can I have some help?

Below is what I had, but I’m aware is not exponential and when it reaches 0.65 the `spriteHorizontalPosition` is suddenly yanked to its max and looks awkward.

``````let turnRadius = user.input;

} else if (turnRadius >= 0.65 ) {
}

spriteHorizontalPosition = ((turnRadius * -1) + 1) * 137.5;

if ( spriteHorizontalPosition >= 275 ) {
spriteHorizontalPosition = 275;
}

else if ( spriteHorizontalPosition <= 0 ) {
spriteHorizontalPosition = 0;
}

playerSprite.transform.x = spriteHorizontalPosition;
``````

Source: JavaSript – Stack Overflow

October 2, 2021
Category : News

### Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.