I need to understand this please

 

I have global variable that is used in function, then I use script to test the function result using the alert function


Alert("Variable","Function());

Alert(" Function ()","Variable");

but when I alert the result of the function and the global variable the result differs if I mention the variable before the function, I get the global variable with the value that should have been assigned to the function correctly, but when I mention the function before the variable, the variable show the initialize value


Can someone explain to me this please?


Thanks

 

Michael: I have global variable that is used in function, then I use script to test the function result using the alert function.

Alert("Variable","Function());

Alert(" Function ()","Variable");

but when I alert the result of the function and the global variable the result differs if I mention the variable before the function, I get the global variable with the value that should have been assigned to the function correctly, but when I mention the function before the variable, the variable show the initialize value. Can someone explain to me this please? Thanks

You did not show log output or screenshots of the Alert, and the code you have shown is incomplete and invalid.

We cannot see your computer nor read your mind. If you want us to help identify the reason, you will have to provide more details.

Show code that will compile and demonstrate the issue when run, Show also log output or screenshots.

 

Yes sure, here are the SS, and thanks for your help in advance 

as below in SS I just changed the order of the global variable and the function in the alert function which reflected on the value of the global variable as once it has the correct value that it should be assigned to it by the function and the other time it has the initiation value "8501"

I just need to understand why the order of the parameters in the alert function reflected in the result of the variable, noting that this global variable is used only by this function

thanks


 
Michael #: Yes sure, here are the SS, and thanks for your help in advance as below in SS I just changed the order of the global variable and the function in the alert function which reflected on the value of the global variable as once it has the correct value that it should be assigned to it by the function and the other time it has the initiation value "8501" I just need to understand why the order of the parameters in the alert function reflected in the result of the variable, noting that this global variable is used only by this function thanks

Yes, you supplied screenshots, but unfortunately you ignored the main request — source code that can be compiled and run that demonstrates the issue.

Without the rest of the code to analyse, we cannot tell when and how it is updated.

For example, is the "TheSupply()" function perhaps changing the value of that "TheBoCandleSupply" variable when it is called?

If yes, then that would explain the reason why changing the order will affect the value of the variable.

So, without the source code, we can only speculate.

Reason: