consider the following javascript code, console.log always prints "focus 1" where 2 is the input length.
how should I rewrite the code to prints the looping variable i correctly
for (var i = 0; i < inputs.length; i++) {
var curIndex = i;
inputs[i].addListener('focus', function(thisfield, evt){
console.log('focus '+curIndex);
});
}