JavaScript Math Object : round()

The round() method Returns the value of given number, rounded to its nearest integer. Syntax :
  Math.round( number );
Example :
<script>
  var x = -5.32;
  var y = Math.round(x);
  document.write("round(-5.32) : " + y + "<br/>");
  var x = 12.56;
  var y = Math.round(x);
  document.write("round(12.56) : " + y + "<br/>");
  var x = 20.49;
  var y = Math.round(x);
  document.write("round(20.49) : " + y + "<br/>");
</script>
Output :



Next Topic :