How to use Math.floor() Method In Javascript
Math.floor() method is used to round off the number to its nearest integer and returns the smallest integer greater than or equal to the given number.
Example: The below code illustrates how to remove the decimal part of a number Using Math.floor() Method.
Javascript
console.log(Math.floor(-12.10)); console.log(Math.floor(0.79)); |
Output:
-13
0
How to Remove the Decimal Part of a Number in JavaScript ?
The decimal portion of a number in JavaScript can be removed through various methods, including the Math. trunc( ) method, Math. floor( ) method, Math. ceil( ) method, and Math. round( ) method.
Contact Us