Math.max() Method - Math Functions

Math.max() method of Math Functions in Javascript.
How to get the highest valued number in javascript?


Object: Math
Method: Math.max()
Description: To get the max valued number or the highest number out of a set of numbers. The below example will get the highest value from the inputed numbers using Math Functions.


<script type="text/javascript">
function maxnum()
var one=document.frm.num1.value;
var two=document.frm.num2.value;
alert('Maximum value is::'+ Math.max(one,two));
<form name=frm>
First Number :<input type="text" name="num1" size=10>
Second Number :<input type="text" name="num2" size=10>
<input type="button" value="Show Max number" onClick="maxnum()">


First Number :
Second Number :

In the above example,
  • Using a form two numbers are got as input.
  • Math.max() function is used to get the highest out of the two numbers.

Ask Questions

Ask Question