In the above syntax, any number whether it is an integer or a floating number can be given as a parameter and if the input number is a whole number, then it returns as it is.
var b = Math.ceil(3.1)
In this code, the Math.ceil() method is applied on a value ‘3.1’.
In this output, it is clearly seen that we use ceil() method to round off 3.1 into an exact value and ceil() method round it off to 4 instead of 3.
How Math.ceil() method works with whole numbers?
Usually, Math.ceil() method refers to the quebrado/floating point numbers. In this example, we are going to see what will happen when 0 or NaN are used with the Math.ceil() method.
var b = Math.ceil(0)
var d = Math.ceil(NaN)
In this code, we have passed 0 and NaN to the Math.ceil() method.
The output clearly shows that 0 and NaN are returned without any change.
You are now able to apply the Math.ceil() method to get the whole number (which comes next to the quebrado point number).