JavaScript Math object : abs()

The abs() method Returns the absolute value of a number. Syntax :
  Math.abs( number );
Example :
<script>
  var x = -10.89;
  var y = Math.abs(x);
  document.write("abs(-10.89) : " + y + "<br/>");
  var x = -20.675;
  var y = Math.abs(x);
  document.write("abs(-20.675) : " + y + "<br/>");
  var x = 30;
  var y = Math.abs(x);
  document.write("abs(30) : " + y + "<br/>");
</script>
Output :



Next Topic :