Global variable across many functions

Thanks I seem to have found the answer. I simply took out the « var » in the init function and everything seems to work now. :smile:

I am a teacher and I am making a small interactive game for the students to review the novel Dr. Jekyll and Mr. Hyde. Most of it is done but I wanted to let them know at the end how they had done, good answers versus bad. I thought that I’d use a counter for both like x = ++x but I can’t seem to make it work across all the functions. All I get is a NaN as an answer. Here are examples of the functions.

Thanks I seem to have found the answer. I simply took out the « var » in the init function and everything seems to work now. :smile:

Hi Denis

When setting variables and using

var

you cannot use a “.” in the variable as it creates an ‘unexpected token’ error.

just create your variable as

window.right = 0;
1 Like