Math.abs
The Math.abs method returns
the modulus (or absolute value) of
a number, that is, it makes a
positive number from a negative
number.
Syntax
javascriptMath.abs(number);
Example
Let's output the modulus of
the number -3:
javascriptconsole.log(Math.abs(-3));
The code execution result:
javascript3
Example
Let's output the modulus of
the number 3:
javascriptconsole.log(Math.abs(3));
The code execution result:
javascript3