Introduction to JavaScript math.ceil function usage


Math.ceil(x) - returns the smallest integer (integer function) that is greater than or equal to a numeric parameter, rounding up the number

Ceil is an abbreviation of ceiling, the Chinese word for ceiling

Reference site: http://www.dreamdu.com/javascript/Math.ceil/

Ceil function syntax

Math. Ceil (x);

Ceil function parameter

X — a number of type number

The ceil function returns the value

Returns the smallest integer greater than or equal to x

Example of ceil function

Document. The write (math.h ceil (5.99)); Document. The write (math.h ceil (5.99)); Document. The write (math.h ceil (1.01)); Document. The write (math.h ceil (1.01));

Results:

6 - 5 2 - 1