2 ms·
Each iteration is a new scope, so you need to redefine the variable. If you used an if statement to define the variable in only one iteration of the loop, then
by ihuman 6y ago
Each iteration is a new scope, so you need to redefine the variable. If you used an if statement to define the variable in only one iteration of the loop, then the reference will be undefined in future iterations.