Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Implement a custom event emitter class with methods on, emit, and off.

Hard

Problem Statement

Implement a custom event emitter class with methods on, emit, and off.

Sample Input

Register and emit an event hello.

Sample Output

Hello, World!

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
class EventEmitter { private events: { [key: string]: Function[] }; on(event: string, listener: Function): void { // Your logic here } emit(event: string, ...args: any[]): void { // Your logic here } off(event: string, listener: Function): void { // Your logic here } }
Log in or sign up to run or submit your code.Log inSign up
Input
Register and emit an event hello.
Expected Output
Hello, World!