Continuation-passing style (CPS) makes control explicit by passing the rest of a computation as a callback. It helps untangle asynchronous code by separating nested callbacks into named functions or lambda expressions, reducing unnecessary closures and making each step easier to follow. section 8.1
Refactoring asynchronous student retrieval
Instead of nesting callbacks while retrieving student information and grades, define separate handlers such as handleClickEvent, showStudent, processGrades, and handleError. Pass the next handler directly to getJSON, so each callback represents the current continuation. When asynchronous requests run inside a loop, pass the current student into a dedicated function to give each callback the correct closure.
