polyline: Only declare i variable once

Javascript only has function-wide scoping...