JavaScript min() Method
This method returns number with lowest value
Here is the example of math.min()
<p>Click the button to return the lowest number of 5, 10,2,0.</p>
<button onclick="myFunction()">result</button>
<p id="mi"></p>
<script>
function myFunction() {
document.getElementById("mi").innerHTML = Math.min(15, 10,2,0);
}
</script>
</body>
</html>
Output
0
JavaScript max() Method
This method returns number with highest value
Here is the example of math.max()
<!DOCTYPE html>
<html>
<body>
<p>Click the button to return the highest number of 5,10,2,0.</p>
<button onclick="myFunction()">result</button>
<p id="ma"></p>
<script>
function myFunction() {
document.getElementById("ma").innerHTML = Math.max(5,10,2,0);
}
</script>
</body>
</html>
Output
10
0 Comment(s)