Math.round method

The Math.round method rounds to the nearest integer using the rules of mathematical rounding.

Syntax

javascriptMath.round(number);

Example

Let's round the number 6.4 to the nearest whole number:

javascriptconsole.log(Math.round(6.4));

The code execution result:

javascript6

Example

Let's round the number 6.6 to integers:

javascriptconsole.log(Math.round(6.6));

The code execution result:

javascript7

Example

We round the number 6.5 up to integers:

javascriptconsole.log(Math.round(6.5));

The code execution result:

javascript7

Example

We round the number 6.49999 up to integers:

javascriptconsole.log(Math.round(6.49999));

The code execution result:

javascript6

See also