6. Events and Handlers

Code that waits for something to happen

Apps don't run top to bottom — they wait. When a key is pressed or a button is clicked (an event), the app runs the function registered for it (the handler).

🎯 0/4 · 🥁 0 solved · 🏅 0

Challenge A:events is a pretend list of key presses: [key, beat]. handlers maps keys to drums. For each key, beat in events, call handlers[key](beat).

Goal
snare
kick
1234
5678