offline version v3


32 of 264 menu

Math.round method

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

Syntax

Math.round(number);

Example

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

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

The code execution result:

6

Example

Let's round the number 6.6 to integers:

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

The code execution result:

7

Example

We round the number 6.5 up to integers:

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

The code execution result:

7

Example

We round the number 6.49999 up to integers:

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

The code execution result:

6

See also

enru