Home » JavaScript Math ceil() Method

JavaScript Math ceil() Method

by Online Tutorials Library

JavaScript Math ceil() method

The JavaScript math ceil() method increases the given number up to the closest integer value and returns it. If the given number is already an integer, the ceil() method returns it directly.

Syntax

The ceil() method is represented by the following syntax:

Parameter

num – A number.

Return

A smallest integer value, greater than or equal to the given number.

JavaScript Math ceil() method example

Here, we will understand ceil() method through various examples.

Example 1

Let’s see an example to increases the given number up to the closest integer value.

Test it Now

Output:

8  1  

Example 2

In this example, we will use ceil() method with negative numbers.

Test it Now

Output:

-7  0  

Example 3

Here, you can test ceil() method with your own test cases.

Test it Now

Next TopicJavaScript Math

You may also like