Round the number with Math.round() in JavaScript
Description
The following code shows how to round the number with Math.round().
Example
<!--from w ww .j ava 2s .c o m-->
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
document.writeln(Math.round(25.9)); //26
document.writeln(Math.round(25.5)); //26
document.writeln(Math.round(25.1)); //25
</script>
</head>
<body>
</body>
</html>
The code above generates the following result.
Javascript Tutorial Math
Calculate an exponent power in JavaScript
Calculate the absolute value of num in Java...
Calculate the arccosine of a number in Java...
Calculate the arctangent of the quotient of...
Calculate the cosine of a number in JavaScr...
Calculate the natural logarithm (base E) of...
Calculate the sine of a number in JavaScrip...
Calculate the square root of a number in Ja...
Calculates and returns the arcsine of a num...
Calculates the arctangent of a number in Ja...
Calculates the tangent of a number in JavaS...
Check if input value is a number from form ...
Convert Fahrenheit to Celsius back and fort...
Find out the max value in an array in JavaS...
Find out the min value in an array in JavaS...
Find out the value of PI in JavaScript
Find out the value of base 10 logarithm of ...
Find out the value of base 2 logarithm of e...
Find out the value of e, the base of the na...
Find out the value of natural logarithm of ...
Find out the value of natural logarithm of ...
Find out the value of square root of 2 in J...
Generate a random integer between 2 and 10 ...
Generate random URL in JavaScript
Get a random number between 1 and 10 in Jav...
Get a random number between values 0 and 1 ...
Get the max value in a list of parameter in...
Get the min value in a list of parameter in...
Math.round a random number in JavaScript
Round numbers down to the nearest integer v...
Round numbers up to the nearest integer val...
Round to get the smallest integer greater t...
Select a random item from an array in JavaS...
Use Math.PI to do calculation in JavaScript
Use Recursive function to calculate Fibs in...
Calculate an exponent power in JavaScript
Calculate the absolute value of num in Java...
Calculate the arccosine of a number in Java...
Calculate the arctangent of the quotient of...
Calculate the cosine of a number in JavaScr...
Calculate the natural logarithm (base E) of...
Calculate the sine of a number in JavaScrip...
Calculate the square root of a number in Ja...
Calculates and returns the arcsine of a num...
Calculates the arctangent of a number in Ja...
Calculates the tangent of a number in JavaS...
Check if input value is a number from form ...
Convert Fahrenheit to Celsius back and fort...
Find out the max value in an array in JavaS...
Find out the min value in an array in JavaS...
Find out the value of PI in JavaScript
Find out the value of base 10 logarithm of ...
Find out the value of base 2 logarithm of e...
Find out the value of e, the base of the na...
Find out the value of natural logarithm of ...
Find out the value of natural logarithm of ...
Find out the value of square root of 2 in J...
Generate a random integer between 2 and 10 ...
Generate random URL in JavaScript
Get a random number between 1 and 10 in Jav...
Get a random number between values 0 and 1 ...
Get the max value in a list of parameter in...
Get the min value in a list of parameter in...
Math.round a random number in JavaScript
Round numbers down to the nearest integer v...
Round numbers up to the nearest integer val...
Round the number with Math.round() in JavaS...
Round to get the largest integer number equ...Round to get the smallest integer greater t...
Select a random item from an array in JavaS...
Use Math.PI to do calculation in JavaScript
Use Recursive function to calculate Fibs in...