Latest Code Tutorials

Javascript Math Round Example | JS Math.round()


Javascript Math.round() is an inbuilt function that returns the value of a number rounded to the nearest integer. If the fractional portion of an argument is more than 0.5, the argument is turned to an integer with the next higher absolute value. If it is less than 0.5, then the argument is rounded to the integer with the lower value.  If the fractional portion is exactly 0.5, then the argument is rounded to the next integer in the direction of +∞.

Javascript Math Round Example

The syntax of Math.round() is following.


Where is a number. The value of a given number rounded to the nearest integer.

Let’s see the following example.

// app.js


OutputJavascript Math Round Example | Math.round() Tutorial

The Math.round() function returns a value of the number rounded to the nearest integer.

If we want to round off a number to its nearest integer, the Math.round() function should be implemented.

The Math.round() function itself rounds off a negative number when passed as the parameter to it. See the following example.

// app.js


OutputMath.round() Tutorial

Finally, Javascript Math Round Example Tutorial is over.

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.