Computer >> Computer tutorials >  >> Programming >> Javascript

Math.floor() function in JavaScript


The floor() function of the Math object accepts a floating point number and returns the largest integer less than or equal to the given number. If the given number itself is an integer this function returns the same.

Syntax

Its Syntax is as follows

Math.floor(160)

Example

<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var result = Math.floor(160.98);
      document.write("Floor value: "+result);
   </script>
</body>
</html>

Output

Floor value: 160