JavaScript USES the Max function to return the larger of two Numbers


This example shows how JavaScript USES the Max function to return the larger of two Numbers. Share with you for your reference. The details are as follows:

The Math object of JavaScript has an max function to get the larger number of two Numbers. The following code demonstrates the use of max in detail

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

Run result output: 10

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