Let me first admit that my class doesn’t always pay attention even when I announce that I am going to say something important.
I often see initialization of variables in the wrong place. Students will put var x = __; at the top of their programs with the assumption that it will somehow run more than once. They should be putting var x; at the top and x = __; where it actually needs to run. var becomes misunderstood as if initialization is special in some way.
When using blocks, changing from var x = __; to x = __; can result in typos as the first is usually dragged to the garbage and the second inserted after. In text mode it is trivial to make that change, but many of my kids have not switched to text yet when they need to make that change.
For these reasons, I wonder if var x = __; should be removed from the block pallet and var x; and x = __; be taught separately instead.
- the title of this post is an homage to Dijkstra’s “Go To Statement Considered Harmful” https://dl.acm.org/doi/10.1145/362929.362947