How to get the absolute value of a number in JavaScript?
The abs() method returns the absolute value of a number.
Example
Demo
Math.abs(x)Parameter is required and must be a numeric value.
Example
<script>Sample code and demo is here
document.write(Math.abs(7.25) + "<br />")
document.write(Math.abs(-7.25) + "<br />")
document.write(Math.abs(7.25-10))
</script>
Demo
Comments
Post a Comment
Ask me anything here...