Consider the following code:
for (var i=0; i<100; i++) {
// your code here
}
// some other code here
for (var i=0; i<500; i++) {
// custom code her
let
keyword is introduced in javascript 1.7. Please find MDN documentation here
Replacing var
to let
inside for loop
solves the problem and now one can declare local variable inside the scope of a loop. Check out stackoverlow community explanation here: What's the difference between using "let" and "var" to declare a variable?
Code from future:
for (let i = 0; i < someVar.length; i++) {
// do your thing here
}