If a global variable is only ever assigned to but its value is never read, this could indicate dead code, a typo or a logic error.
Ensure that the name of the variable has not been misspelled. If the assignment refers
to an externally defined global variable (such as property of the
object), you can provide an externs file or a JSLint-style
directive to inform the analysis about this variable.
The following example shows a function for counting the number of leaves in a binary
tree. For an inner node, the function first recursively counts the number of leaves
in the left and right subtrees, stores them in variables, and then returns their sum.
The name of the variable holding the number of leaves in the right subtree has been
misspelled: it is spelled
rigtLeaves instead of
assignment stores the number of leaves in the right subtree in a global variable
rigtLeaves, so the algorithm will not work as expected.
To fix this, correct the name of the local variable: