+ 7
JavaScript: How can I assign a variable to a range?
6 ответов
+ 5
function getvalinRange(n,max,min){
return Math.max(Math.min(n, max), min);
}
// n is the number
// max = maximum in range
// min = minimum in range
+ 3
do you want a value between maximum and minimum
+ 3
Jip
+ 1
I know this is late, but the answer you picked (converting the number to one within: minimum ≤ value ≤ maximum) is called clamping the number.