How to round a double value in Javascript?
If the floating-point number is above or equal to x.5 - it's rounded up to the nearest integer. If the floating-point number is below x.5, it's rounded down to the nearest integer:
Math.round(24.49); // 24
Math.round('29.5'); // 30
Math.round(72); // 72
Math.round(-40.51); // -41
The Math.floor() method is used to return the nearest whole integer that is less than or equal to a specified value. In layman's terms, the floor() method rounds a number down and returns an integer result:
Math.floor(75.95); // 75
Math.floor(75.05); // 75
Math.floor(4); // 4
Math.floor('-65.05'); // -66
Math.floor(-65.95); // -66