showing results for - "js clamp"
Morgane
04 May 2016
1function clamp(n, min, max) {
2  if(n > max){
3  	return max;
4  } else if(n < min){
5    return min
6  } else{
7  	return n;
8  }
9}
10//clamp(202, 1,100); //returns 100
11//clamp(50,1,100); //returns 50
12//clamp(-3,1,100); //returns 1