The abs() function of the Math object accepts a number and returns its absolute value.
Syntax
Its Syntax is as follows
Math.abs(3)
Example
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script type="text/javascript">
var result = Math.abs(3);
document.write("Absolute value: "+result);
</script>
</body>
</html>Output
Absolute value: 3