Skip to content
Advertisement

“Unresolved Reference” error within a definition when attempting to edit a variable

When attempting to put some maths that change a variable within a definition, I receive an error specifying “Unresolved Reference”. The following is the code I am using, the relevant code on lines 9 – 15.

JavaScript

The first “Increment” which is under “FIG 1”: incurs the error “Shadows name ‘Increment’ from outer scope”. The second one (under “FIG 2”) causes the “Unresolved Reference” error I already talked about.

Advertisement

Answer

Your Increment variable is a global variable.
So inside your reply function this variable is not known.
You need to add global inside reply function:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement