Consider searching your question before posting. It’s already been answered. By searching you will also find plenty of guides on how to do this.
It simply takes a number and two values - a minimum and maximum. If the number is between the minimum and maximum, it just returns the number. Otherwise, if it’s below the minimum, it’ll return the minimum, or if it’s above the maximum it’ll return the maximum.