To get the largest integer less than or equal to a number, use the Math.floor() method in JavaScript.
Example
You can try to run the following code to get the largest integer less than or equal to a number −
<html> <head> <title>JavaScript Math floor() Method</title> </head> <body> <script> var value = Math.floor(50.3); document.write("First Value : " + value ); var value = Math.floor(20.7); document.write("<br />Second Value : " + value ); var value = Math.floor(-5.8); document.write("<br />Third Value : " + value ); var value = Math.floor(-3.1); document.write("<br />Fourth Value : " + value ); </script> </body> </html>