Answers for "limit number js"

1

javascript restrict number to range

// Restricts number from 20 to 1 
// if number > 20 returns 20
// if number < 1 returns 1
// else returns number
var number = Math.min(Math.max(parseInt(number), 1), 20);
Posted by: Guest on July-06-2020
0

javascript index of biggest number

arr.indexOf(Math.max(...arr))
Posted by: Guest on December-20-2019

Code answers related to "Javascript"

Browse Popular Code Answers by Language