Let's start with the definition of a bug before we start debugging them. Below is a great extract I got from this Hackernoon blog about debugging smart contracts on the blockchain. Super tangent, but ...
Enclosing the whole script in a function does not solve the problem. I snooped arround in Zorro-The Layer Tagger.jsx to replicate an enclosed structure and came up with this example. The function 'run ...