A 9V battery won't power anything except the smallest motors. If you have a multimeter, it's interesting to see what the battery voltage is when you connect a motor directly.
It is quite easy to write a program that compiles without error, but won't do anything useful at all.
The compiler will complain if your program has mistakes which make it impossible for the compiler to understand, but won' tell you if it is logically nonsense.
Your program looks to me as though it should do something, it seems incomplete, but it should do something. If it does nothing, you have some kind of power supply or wiring problem.
Probably the moment he tries to turn on the motor, the voltage on the battery droops so low that it resets the board - if he's using one of those common rectangular 9v batteries, that's what I'd expect to happen. Those are only for low current, ie, not motors - but people seem drawn to them because they look like an easy way to get 9v.