Math.min() Method - Math Functions
Math.min() method of Math Functions in Javascript.
How to get the Lowest number in javascript?
Explanation
Object:
MathMethod:
Math.min()Description: To get the minimal or lowest number from the numbers listed. The below example will get the minimal or the lowest number from the entered numbers using math functions.
Example:
<html>
<script type="text/javascript">
function minnum()
{
var one=document.frm.num1.value;
var two=document.frm.num2.value;
alert('Minimum value is::'+ Math.min(one,two));
}
</script>
<form name=frm>
First Number :<input type="text" name="num1" size=10>
<br><br>
Second Number :<input type="text" name="num2" size=10>
<br>
<input type="button" value="Show Min number" onClick="minnum()">
</form>
</html>
Result:
In the above example,
- Two numbers are got a input using a form.
- Math.min() method is used to get the lowest number out of the two.