round
This function rounds a value to its nearest equivalent based on the number of decimal places you specify.
double round(double value, int decimal_places)
Parameters:
value
The value to round.
decimal_places
The number of decimal places to round to.
Return value:
The specified value rounded to the specified number of decimal places.
Remarks:
This function will round the value up or down where appropriate. The decimal_places parameter controls how the function should round. A value greater than 0 specifies a number of decimal places, 0 specifies the nearest integer, and negative values will round to the nearest tens, hundreds, thousands etc.
Example:

    void main()
    {
    alert("round test", "5.31 rounded to 1 decimal place is "+round(5.31, 1)+".");
    alert("round test", "5.37 rounded to 1 decimal place is "+round(5.37, 1)+".");
    alert("round test", "5.73 rounded to the nearest integer is "+round(5.73, 0)+".");
    alert("round test", "5.31 rounded to the nearest ten is "+round(5.31, -1)+".");
    }