javascript restrict number to range

Solutions on MaxInterview for javascript restrict number to range by the best coders in the world

showing results for - "javascript restrict number to range"
Gaia
23 Sep 2017
1// Restricts number from 20 to 1 
2// if number > 20 returns 20
3// if number < 1 returns 1
4// else returns number
5var number = Math.min(Math.max(parseInt(number), 1), 20);