Setting a global variable in Javascript

Someone on the forum answered to set a global variable value in javascript it looks like this:

runtimeScene.getGame().getVariables().get(“globalVarName”).setString(“new text”);

I don’t know what to say it just doesn’t work.

i tried like
runtimeScene.getGame().getVariables().get(glossary).setString(myLex);
and
runtimeScene.getGame().getVariables().get(“glossary”).setString(“ScrapShot”);

It flashes me a critical error in the debug log that “glossary” is not defined.

I open global variables in the editor and i do have a variable named glossary which is a Text variable.

Could you screen shot the global variable screen, the javascript event and the error message?

Are any of the letters in the editor in red?

The variable name needs to be in quotes otherwise Javascript will expect an object or something.

Something that has happened to me when copying stuff from the web is the quotes get changed and it doesn’t have the right type. Javascript can use the single or double quotes but not the ones that are curved with opening and closing styles.

Extensions don’t usually need to modify global variables directly.
Why do you need this ?