Hi there! So the JS code is a little tricky here. Every external function, in this case .trigger and .setValue, happens asynchronously together at the end of the JS query using the values that are defined at that point internally in the JS code. So what is happening here is:
Query runs, evaluates textOutput.value
textOutput’s value is set to ‘Init:’
myQuery is run, with an onSuccess function that is defined using the original value of textOutput.value
textOutput’s value is set to that textOutput.value property, with the data +='ed to it.
To put it another way, here’s what you could expect from this code section:
let val = tempState.value;
console.log(val); //returns "Original Value"
console.log(tempState.value); //returns "Original Value"
//In the browser console you'll see
Setting value of tempState to "Hello!"