JavaScript(JS) math method - floor

The floor method in JavaScript's Math object returns the largest integer less than or equal to a given number. In other words, it rounds down to the nearest integer.

The floor method takes one argument, which is the number to be rounded down. If the argument is not a number, it will be converted to one before the calculation. If the argument is NaN, NaN will be returned.

Here's an example usage:

refe‮igi:ot r‬ftidea.com
const x = 3.7;
const floorX = Math.floor(x);
console.log(floorX); // 3

In the above example, the Math.floor method is used to round down the number 3.7 to the nearest integer, which is 3. The result is then logged to the console.