Here is a code snippet that listens for the main and initial events. You should emit the main event inside the initial event handler so that the appropriate line is printed to the console.
Intro to events module
Inner emitter
Report a typo
Write a program in JavaScript
const EventEmitter = require('events'); //do not change this line!
const emitter = new EventEmitter();
emitter.on('main', () => {
console.log('It is main event!')
})
emitter.on('initial', (eventName) => {
/* your code */
});
emitter.emit('initial', /* your code */);
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.