You're using var
to declare variables within a block:
var i, max = 10;
for (i = 0; i < max; i++) {
var timesLooped = i + 1;
console.log('Times looped:', timesLooped);
}
Use ES6 let
instead:
var i, max = 10;
for (i = 0; i < max; i++) {
let timesLooped = i + 1;
console.log('Times looped:', timesLooped);
}