`var i` is declared a few times in this function. It’s probably worth consolidating those declarations, declaring it right before `n`.