Javascript Reference - JavaScript round() Method








The Math.round() method is a standard round function. Math.round() rounds up if the number is at least halfway to the next integer value (0.5 or higher) and rounds down if not.

2.49 will be rounded down, 2.5 will be rounded up.

Browser Support

round() Yes Yes Yes Yes Yes

Syntax

Math.round(x);




Parameter Values

Parameter Description
x Required. The number to round

Return Value

A number representing the nearest integer.

Example


console.log(Math.round(25.9)); //26 
console.log(Math.round(25.5)); //26 
console.log(Math.round(25.1)); //25 

The code above generates the following result.