Forum Discussion
When translated into simple JavaScript, your trigger action would resemble something like this:
In the provided code, if isTrue
is true
, the else
statement will never execute. It will only execute the if
block.
If you set isTrue
to false
within the if
statement, it will alter the value of isTrue
before the else
block is reached. Here's how it would look:
Even in this case, when the button is clicked for the first time, it will set isTrue
to false
and then perform "action A". Subsequent clicks will execute "action B" because isTrue
will be false
.
Your code didn't work because the interaction relies on a click event; nothing will occur until you click, and more important the "Reached_top" variable maintains the value of true after the initial button click. Therefore, you should implement a trigger to toggle the "Reached_top" variable.
Triggers in the final version will resemble the JavaScript below. The handleClick
function toggles the value of isTrue
using the !
operator, which negates its current value. Then, based on the new value of isTrue
, it performs either "action A" or "action B".
I'm not very skilled at explanations, but I hope this sheds some light on your inquiry.