JavaScript | Math.round( ) function

The Math.round() function in JavaScript is used to round a number to its nearest integer. If the fractional part of the number is greater than or equal to .5, the argument is rounded to the next higher integer. If the fractional part of the number is less than .5, the argument is rounded to the next lower integer.

Syntax:

Math.round(var);

Parameters: This function accepts a single parameter, var. It is the number which you want to round off.



Return Value: The Math.round() function returns the value of the given number rounded to the nearest integer.

Below are some examples to illustrate the Math.round() function: