12 Knock Lock: Where to write your own function?

https://github.com/arduino/Arduino/blob/master/build/shared/examples/10.StarterKit/p12_KnockLock/p12_KnockLock.ino#L149
Why do I not write the function before the loop() if the circuit seems to react the same?