JS linting, use event listeners, complete `fixUp` escape function

i'm curious, why is it preferred to hoist the vars, rather than write them in the loop they are used? because of potential scoping confusion?