Math.max()



Q: What does Math.max() do?


When you use this method it will give you the largest value among a group of numbers.


Q: How do I use it?


NOTE: This method needs you to specify numbers for the multiple compaired values. If at least one of the arguements cannot be converted to a number then NaN is given. If there are no arguements given, this results in -Infinity.


Syntax:


			

//make sure to put in numerical values seperated with commas

 Math.max(x, y, z, ..., ...);

			
		

Example:



Script:


					

function maxexample() {
    document.getElementById("max").innerHTML = Math.max(2, 4, 6, 6, 10);
}
				
					


Go to page

Back to main page