Math.floor() JavaScript Function
Math.floor() is a function in JavaScript that returns the largest integer that is not greater than the number. The number can be a decimal number, and Math.floor() will truncate (or cut off) the decimal part of the number, returning only the integer part.
For example, if you enter the number 5.6 into a JavaScript console, Math.floor() javascript function will return 5. If you enter the number -5.6 into a JavaScript console, Math.floor() will return -6.
How to use Math.floor() javascript function
This function is useful when you need to round a number to the nearest whole number. For example, let’s say you have a number of 5.5 and you want to round it down to the nearest whole number. You would use the Math.floor() function like this:
Math.floor(5.5)
This would return the number 5.