To handle the possibility that chestLid could be null, we’ll use an if-statement to only run the next line if it does, in fact, exist. To do this, we need the NOT-EQUALS operator, !=.
- Before the chestLid sendEvent line, add an if statement.
- Move the final } curly bracket to be after the chestLid sendEvent line.
- Make the condition of the if-statement that the chestLid does not equal null
- Indent the chestLid sendEvent line.