Syntax:
Math.round(x)
Example
<script type="text/javascript">
document.write(Math.round(0.75) + "<br />");
document.write(Math.round(0.50) + "<br />");
document.write(Math.round(0.25) + "<br />");
document.write(Math.round(-4.30) + "<br />");
document.write(Math.round(-4.88));
</script>
OUTPUT:
1
1
0
-4
-5
Math.round(x)
Example
<script type="text/javascript">
document.write(Math.round(0.75) + "<br />");
document.write(Math.round(0.50) + "<br />");
document.write(Math.round(0.25) + "<br />");
document.write(Math.round(-4.30) + "<br />");
document.write(Math.round(-4.88));
</script>
OUTPUT:
1
1
0
-4
-5
No comments:
Post a Comment