i inputted the following code into Chrome's javascript console:
function test() {
var a = [1, 2, 3, 4];
for (var i = 0; i < a.length; i++) {
var a = i;
console.log(a);
}
console.log(a);
}
test();
When I called test(), instead of getting the values 0,1,2,3, I got 0 twice. It appears the loop only ran once, does anyone know why?