How to create a function to scale numbers when the range is in the center.
Let's say 300 is the center position between 0 and 600. How do you calculate if the range is less than 0 the return should have 0.2 and when the range is greater than 600 the return should have 0.2 as well however if the range is 300 the return should have 1.2
let range = 300;
let max_range = 600;
const getScaleNumber = (range, max_range) => {
return (range / max_range) * 2.4;
}
The given formula returns a 1.2 number which is what I expected if the range is in the center of 0 and 600 however if I did the 0(range) / 600 * 2.4 it returns 0, and it should return 0.2 if the range is less than 0 or greater than 600
How to create a function that increases and decreases a return number with a minimum return of 0.2 and a maximum return of 1.2.