The function "converting negative numbers to positive numbers and vice versa" is called negation. In order to use it you have to put a minus sign in front of the variable or constant.
Code:
var x = 3;
var y;
y = -x; // This makes the magic happen...
Always learn from history, to be sure you make the same mistakes again...