Convert a negative number to a positive one in JavaScript
What about x *= -1
? I like its simplicity.
You could use this...
Math.abs(x)
Math.abs()
| MDN
What about x *= -1
? I like its simplicity.
You could use this...
Math.abs(x)
Math.abs()
| MDN