How to use the round in JavaScript

In this article we will discuss about how to use the round() method in JavaScript.
  • 1765

This is is the most important method of Math Object in JavaScript. This method returns the round of value to the nearest integer. Here is the following syntax to use this function which is as follows:



Here y is the number given to it of which a round of value will be find out.

JavaScript Code:



    <title>JavaScript Math round() Method</title>



    <script type="text/javascript">


        var roundvalue = Math.round(0.7);

        document.write("First Test Value : " + roundvalue



        var roundvalue = Math.round(21.8);

        document.write("<br />Second Test Value : " +



        var roundvalue = Math.round(50.3);

        document.write("<br />Third Test Value : " +



        var roundvalue = Math.round(-10.2);

        document.write("<br />Fourth Test Value : " +







Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2020 DotNetHeaven. All rights reserved.