The JavaScript Math.round() method rounds a number to the nearest integer. It rounds up for decimal values of 0.5 and higher, and down otherwise.
Syntax:
Math.round(value);Parameters:
- value: It is the number that you want to round off.
Return Value:
The Math.round() method returns the value of the given number rounded to the nearest integer.
Example 1: To round off a number to its nearest integer.
let round =Math.round(-5.8);
console.log("Number after rounding : " + round);
Output
Number after rounding : -6
Example 2: The Math.round() method itself rounds off a negative number when passed as a parameter to it. To round off a negative number to its nearest integer, the Math.round() method should be implemented in the following way:
let round =Math.round(-5.8);
console.log("Number after rounding : " + round);
Output
Number after rounding : -6
Example 3: The below program shows the result of the Math.round() method when the parameter has ".5" in decimal.
let round =Math.round(-12.5);
console.log("Number after rounding : " + round);
let round1 =Math.round(12.51);
console.log("Number after rounding : " + round1);
Output
Number after rounding : -12 Number after rounding : 13
We have a complete list of Javascript Math Objects methods, to check those please go through this Javascript Math Object Complete reference article.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
