Others



JavaScript Math.round()


The Math.round(x) method used to returns the rounded to the nearest integer.

Syntax
Math.round(x)

Here, round() is a static method. Hence, we use it as Math.round().

Parameters
  • x - (Required).A number.
Return Value
  • Number - The value of x rounded to the nearest integer.
Example
console.log(Math.round(10.5));  //11
console.log(Math.round(10.2));  //10
console.log(Math.round(10.7));  //11
console.log(Math.round(-10.5)); //-10
console.log(Math.round(-10.2)); //-10
console.log(Math.round(-10.7)); //-11
Try it Yourself

JavaScript Math Functions