如何用javascript将-1转换为1?

far*_*oft 1 javascript variables integer negative-number

如何用javascript将-1转换为1?

var count = -1; //or any other number -2 -3 -4 -5 ...
Run Code Online (Sandbox Code Playgroud)

要么

var count = 1; //or any other number 2 3 4 5 ...
Run Code Online (Sandbox Code Playgroud)

结果应该是

var count = 1; //or any other number 2 3 4 5 ...
Run Code Online (Sandbox Code Playgroud)

Mit*_*sey 17

 count = Math.abs(count)
 // will give you the positive value of any negative number
Run Code Online (Sandbox Code Playgroud)