0
0
Expressframework~10 mins

Event-driven architecture in Express - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the EventEmitter class from the 'events' module.

Express
const [1] = require('events');
Drag options to blanks, or click blank then click option'
AEmitterClass
BEventEmitter
CEmitter
DEvent
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect class names like 'Emitter' or 'Event'.
Forgetting to import from 'events' module.
2fill in blank
medium

Complete the code to create a new instance of EventEmitter.

Express
const emitter = new [1]();
Drag options to blanks, or click blank then click option'
AEventEmitter
BEmitter
CEvent
DEventClass
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect class names like 'Emitter' or 'Event'.
Forgetting the parentheses to create an instance.
3fill in blank
hard

Fix the error in the code to listen for the 'start' event.

Express
emitter.[1]('start', () => {
  console.log('Started');
});
Drag options to blanks, or click blank then click option'
Alisten
BonStart
Con
DaddListener
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like 'listen' or 'onStart'.
Confusing event registration with event emitting.
4fill in blank
hard

Fill both blanks to emit a 'data' event with a message.

Express
emitter.[1]('[2]', 'Hello World');
Drag options to blanks, or click blank then click option'
Aemit
Bon
Cdata
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'on' instead of 'emit' to trigger events.
Using wrong event names.
5fill in blank
hard

Fill all three blanks to create an event listener that logs the received message.

Express
emitter.[1]('message', ([2]) => {
  console.log([3]);
});
Drag options to blanks, or click blank then click option'
Aon
Bmsg
Demit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'emit' instead of 'on' to listen.
Using different variable names inconsistently.