What does Math.floor() do? How do I use it?


#1

Question

What does Math.floor() do? How do I use it?

Answer

Math.floor(number) will return the largest whole number (integer) that is less than or equal to the number passed to the Math.floor function.

Example usage:

Math.floor(8.7124); //will return the number 8
Math.floor(147/9); //will return the number 16