Math.floor()



Q: What does Math.floor() do?


When you use this method it will give you the largest integer that is less than or equal to the specified number. So it will basically round down to the nearest integer of this specified number.


Q: How do I use it?


NOTE: This method needs you to specify a number for the value of x.

Syntax:


			

//make sure you put in a numerical value for x

Math.floor(x);

			
		

Example:



Script:


					

function floorexample() {
    document.getElementById("floor").innerHTML = Math.floor(4.3);
}
				
					


Go to page

Back to main page