Estimate JS interest
I have two variables.
let valMax = 29 let valNow = 15 let valEnter = ?
variable valMax No change, variable valNow Always change.
The simplest thing is
100 * текущее / максимальное
100 * (current - min) / (max - min)
a Reflecting borders and the inability to overcome them (in some cases no more than 100 per cent or less than 0 per cent)
(current < min) ? 0 : (current > max) ? 100 : (100 * (current - min) / (max - min))