jquery - How can I use JavaScript to limit a number between a min/max value? -


i want limit number between 2 values, know in php can this:

$number = min(max(intval($number), 1), 20); // make $number 1 if it's lower 1, , 20 if it's higher 20 

how can in javascript, without having write multiple if statements , stuff that? thanks.

like

var number = math.min(math.max(parseint(number), 1), 20); 

Comments

Popular posts from this blog

How can I edit my VIM config so that Vim treats ".ejs" files the same as it currently treats my html files? -

Python __call__ special method practical example -