0

Variable conflict?

I'm having trouble with variables/variable checks

I have a variable x, with the initial value 0 that increases by one for every button tap. When a different button is pressed it checks the variable to determine the states of 2 containers:

({x} >=10) ? "State 2" : "State 3")

({x} >=10) ? "State 1" : "State 2")

If I trigger that button, it works the first time;

1. If x<10, it goes to the appropriate States. Then I increase x so that x >= 10 and I still get the x<10 results.

2. If x>=10, the button is pressed and it changes the States appropriately and the State interaction Sets variable x to 0. But tapping the button that checks if {x} >=10 now produces the result as if x>=10 even though the State change should set x to 0.

I'm not sure what could be causing this, as text is displaying which confirms the value of x, and the x >=10 ? check works accurately the first time it is called (as I explained above)

1 comment

Please sign in to leave a comment.