Error on prorammatically accessing global variable [closed]

My code loads a value to a global variable like this:

str="global";
...
window[str+"w"]=100;

This code works fine on desktop browser. But in the mobile browser (Samsung Internet ore Chrome) the global variable remains at the old value.

When the value of the global variable is displayed with an alert at the end of the function where the loading is done, it appears that the new value has been loaded. However, when the same operation is performed in a function called later, it is seen that the global variable has the old value.