3
Is there a command (or symbol) that makes the mathematical module a value?
For example: var teste = |10|-|6|;
3
Is there a command (or symbol) that makes the mathematical module a value?
For example: var teste = |10|-|6|;
5
That syntax |n|
does not exist in Javascript, at least for this purpose.
What you’d have to do is use Math.abs()
. Examples:
var teste = Math.abs(10)-Math.abs(6); // 4
var teste = Math.abs(10-6); // 4
var teste = Math.abs(-10-6); // 16
var teste = Math.abs(-10-(-6)) // 4
Obs.: When involving mathematical operations between values, use
Math.abs()
for each value. For example:
Math.abs(10) - Math.abs(-6)
is different fromMath.abs(10-(-6))
. The first returns4
and the second16
.
5
From what I understand you want the module representation in a number. See Math.abs()
console.log(Math.abs(10));
console.log(Math.abs(-10));
Oh yes, I will study about this command, thank you very much !! Math.mod was giving error x.x
Browser other questions tagged javascript mathematics
You are not signed in. Login or sign up in order to post.
Understood how it works, thanks @Dvd, great explanation
– Sora