EasyJavaScriptTypeScript

composeEventHandlers

ReactEventsFunctions

Implement composeEventHandlers(...handlers) that:
1. Returns a single function that calls each provided handler in order.
2. Skips null/undefined handlers.
3. Stops calling subsequent handlers if any handler calls
event.stopPropagation() (check event.isPropagationStopped?.()).

solve(handlerCount, stopAt, callCount) builds composed handlers and
returns which indices were called when triggered.

Sample tests

Test #1All three handlers called, no stop
Input: [["a","b","c"],null]
Output: [0,1,2]
Test #2Stop at index 1 — index 2 not called
Input: [["a","b","c"],1]
Output: [0,1]
Test #3First handler is null — skipped
Input: [[null,"b","c"],null]
Output: [1,2]
Test #4Stop at first handler
Input: [["a","b","c"],0]
Output: [0]
Test #5First two null, only third called
Input: [[null,null,"c"],null]
Output: [2]