Missing `var` before `i`.  THis will make ` global.