A question about If statement,how can i ?

hello everyone, i want to create an if statement but i couldn’t find a way to do it.

I have two variables;

static var a = 0;
var b = 10;

When a is increased by one, i want b to decrease by one, i mean something like this :

if(a+=1){ // what should i put inside the if to say that a is increased by one ?
b-=1;
}

i hope i could tell clearly enough, i need help :).

Are you looking for an equilibrium? You can just use maths for that without any if-tests with one line of code that is efficient.

b = 10 - a;
// b will be 10 if a is 0
// b will be 9 if a is 1
// b will be 5 if a is 5
// and so on...
// That is, the sum of a + b will be 10.

That said, you’d need to keep track of the old value of a and update it later if you go with an if-statement.

if (a = previousA + 1) {
    previousA = a;
    b -= 1;
}