This JavaScript tutorial explains how to use the math feature known as ceil() with syntax and examples.

## Description

In JavaScript, ceil() is a function that is used to return the smallest integer fee that is higher than or equal to a number. In different words, the ceil() function rounds a number up and returns an integer value. Because the ceil() function is a static characteristic of the Math object, it need to be invoked through the placeholder object known as Math.

## Syntax

In JavaScript, the syntax for the ceil() feature is:

`Math.ceil(number);`

Parameters or Arguments

number The number used to locate the smallest integer.

## Returns

The ceil() function returns the smallest integer fee that is higher than or equal to a number.

## Note

Math is a placeholder object that carries mathematical functions and constants of which ceil() is one of these functions.

## Example

Let’s take a appear at an example of how to use the ceil() characteristic in JavaScript.

For example:

```
console.log(Math.ceil(32.65));
console.log(Math.ceil(8.1));
console.log(Math.ceil(-4.2));
```

In this example, we have invoked the ceil() feature using the Math class.

We have written the output of the ceil() function to the internet browser console log, for demonstration purposes, to show what the ceil() characteristic returns.

The following will be output to the internet browser console log:

```
33
9
-4
```

In this example, the first output to the console log lower back 33 which is 32.65 rounded up to an integer value.

The second output to the console log back 9 which is 8.1 rounded up to an integer value.

The 0.33 output to the console log again -4 which is -4.2 rounded up to an integer value. Notice that when dealing with bad numbers, the ceil() feature rounds up towards zero and in this case, again -4 and now not -5.

## Leave a Review