Math.round()
In this chapter you will learn:
round method
The Math.round()
method is a standard round function.
Math.round()
rounds up if the number is at least
halfway to the next integer value (0.5 or higher)
and rounds down if not.
<!DOCTYPE html><!-- ja v a 2 s . com-->
<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>
Next chapter...
What you will learn in the next chapter:
- How to use Math random method
- How to get a random number in a range
- How to get a random value from an array
Home » Javascript Tutorial » Math