Can anyone tell me why this logs 11, instead of 9?
function foo() {
function bar(a) {
i =3;
console.log( a + i );
}
for (var i=0; i<10; i++) {
bar( i *2 );
//I know, infinite loop
}
}
foo();
If i is hard-coded in bar(){}, shouldn't the logged result be 9?
This is part of a Scope class and I am lost.
Thanks.
ibeing used in both thebarfunction and in theforloop?ito the start offoo().