Methods Explanation NN IE ECMA
max() Returns the number with the highest value of two numbers
2.0 3.0 1.0
min() Returns the number with the lowest value of two numbers
2.0 3.0 1.0
random() Returns a random number 2.0 3.0 1.0
round() Returns a number rounded to the nearest whole number 2.0
3.0 1.0
Examples
1. Round
How to round a specified number to the nearest whole number
Coding
<html>
<body>
<script language="JavaScript">
document.write(Math.round(7.25))
</script>
</body>
</html>
Output
7
2. Random Number
How to write a random number
Coding
<html>
<body>
<script language="JavaScript">
document.write(Math.random())
</script>
</body>
</html>
Output
0.3891641494127387
3. Max Number
How to test which number has the highest value.
Coding
<html>
<body>
<script language="JavaScript">
document.write(Math.max(2,4))
</script>
</body>
</html>
Output
4
4. Min Number
How to test which number has the lowest value.
Coding
<html>
<body>
<script language="JavaScript">
document.write(Math.min(2,4))
</script>
</body>
</html>
Output
2