Math.floor() function in JavaScript

HTMLJavascriptWeb DevelopmentFront End Technology

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

 Live Demo

<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
raja
Published on 29-Oct-2018 09:21:48
Advertisements