JavaScript Math round() method

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

Syntax

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

Parameter

num - A number.

Return

The closest integer value of the given number.

JavaScript Math round() method example

Here, we will understand round() 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:

7
1

Example 2

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

Test it Now

Output:

-7
-1

Example 3

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

Test it Now
Next TopicJavaScript Math