Coding task · JavaScript and TypeScript course · Module 9: Design Patterns and Architecture

Exercise: Security Monitoring

Implement a security monitoring system with sensors, alerts and observers.

Task

The index.js file has a SecuritySystem class with sensors and observers (Observer pattern). Fill in the blanks: ___BLANK1___ is the array method that adds the observer in subscribe, ___BLANK2___ is the observer method that notify calls with the alert, and ___BLANK3___ is the comparison operator that gives an alert only to a sensor whose reading is greater than its threshold (a reading equal to the threshold is not an alarm). checkAlerts should return alerts { sensorId, zone, value } and notify all observers about each of them, and triggerEmergencyProtocol(reason) should turn on emergency mode and send the observers the alert { type: 'emergency', reason }.