What we want to have happen right now is that if I say “open”, the chest lid opens. If it happens to already open, we want it to do nothing. For that, we can use the keyword return
, which stops the function early.
- Add an if-statement that checks if the value of
direction
was“open”
AND the chest’sisOpen
property is already true. - Send a message to the console to notify yourself that that happened.
- Use return to have the function stop there.
- Do the same in an else-if-statement if the value of
direction
was“close”
and the chest’sisOpen
property is not true.