`ctx` is a global variable that's being mutated here -- what do you think about parameterizing `drawGrid` to accept `ctx` as an argument to keep the mutations local to the function?

there are significant advantages (ease of comprehension, testing) to keeping state manipulation tightly scoped... best to do that when it's possible :)