JavaScript USES Math.Min to return the smaller of two Numbers

  • 2020-05-26 07:50:05
  • OfStack

This example shows how JavaScript returns the smaller of two Numbers using Math.Min. Share with you for your reference. The details are as follows:

Below, JavaScript returns the smaller of the two Numbers by Math.Min


<!DOCTYPE html>
<html>
<body>
<p id="demo">
Click the button to return the lowest number of 5 and 10.
</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
document.getElementById("demo").innerHTML=Math.min(5,10);
}
</script>
</body>
</html>

Running the above code gives you the number 5

I hope this article has been helpful to your javascript programming.


Related articles: